Throwing and catching deliberate errors in bash

Hello,
In many languages one can throw deliberate errors of a specific kind as well as catch-trap for specific errors. I'm having a hard time determining how to do this in bash 3.2 with it's 'trap' command.
Moreover, I can't figure out whether or not if it's even possible to catch for specific thrown errors defined by a scripter in bash. My own tests have led to a dead end and I haven't come any better understanding from reading the bash info docs, and numerous online and in print examples of the 'trap' command.
Basically, I wish to...
1. First, have scripts throw a specifically, identifiable, unique error when a certain known bad state has been encountered that they can't handle.
2. Secondly, to able to test for whether scripts are throwing an specific error under a certain condition.
3. Trap for and catch only that specific error and then keep on going, performing further automated tests.
Is this possible in bash?
Below is an example which might better illustrate what I've attempted to do. It unfortunately, doesn't do what's needed at the moment. i.e.- It will catch all errors and exits but not a specific one.
#--- The example below traps all errors but not the specific one.
particular_function()
current_status="some known bad condition"
if [ "$current_status" = "some known bad condition" ]; then
# Encountered some known condition we can't handle so throw specific error.
echo "Encountered a, we knew this would happen, type error."
exit -99
fi
testmethod_for_expectederror()
trap 'echo "function threw expected error code as it should."' EXIT
particular_function
testmethod_for_expectederror
echo "Continued passed caught error as desired and continuing further tests..."
Thanks,
-Anthony

{quote:title=BobHarris wrote:}The bash trap statement was not intended as an alternate way to return errors.
But if you want to generate your own signals, then use the kill command.
See "man 1 kill". {quote}
It sounds like I'm attempting to pound a square peg through a round hole? Attempting workarounds, like shaving off the corners of the peg, might eventually just lead to loss of sanity, time wasted - gone forever, never to return.
So, perhaps I'll try some other method.
If it offers a little more clarity, I'm trying determine [how to write tests|http://xp123.com/xplor/xp0101/index.shtml|Test-First Stoplight - write a test first before writing a line of code.], in bash, for situations where a script [should halt executing|http://xunitpatterns.com/Test%20Method.html#Expected%20Exception%20Te st|Expected exception test pattern] when it encounters something it can't handle rather than keep on going causing potential mishaps.
Basically, I would like to avoid causing the [xUnit testing framework|http://www.martinfowler.com/bliki/Xunit.html|xUnit testing frameworks in XP] I'm using [(shUnit2)|http://code.google.com/p/shunit2/|shUnit2 project site] from incorrectly reporting expected errors, that are suppose to be thrown, by a script, as failures. An expected, [correctly thrown error|http://books.google.ca/books?id=gFgndevwMAC&pg=PA163&lpg=PA163&dq=%22exceptiontest%22+%22test+driven+development%22patterns&source=bl&ots=enHrtsSunH&sig=PbbvWbea_VkqVAbdGYZwJDUcygI&hl=en&ei=XQslS qzSDs-EmQfIvqCFCA&sa=X&oi=bookresult&ct=result&resnum=1|Catch expected exceptions and ignore them. in TDD by Kent Beck] should be counted as a success by the framework in that context. Assuming, the script didn't exit in a bad way. At the same time, unforeseen errors should not be blocked and should propagate up to be reported as an erring test.
Thanks for your help,
-Anthony

Similar Messages

  • Wehre can i find all the throw and catch exceptions

    I havent had much success figuring out which predefined exceptions i should/can use. Can someone please guide me where i can find out what kind of throw and catch exceptions are there in java and how and where can i find them. thanks.

    Read this first: http://java.sun.com/docs/books/jls/second_edition/html/exceptions.doc.html#44044
    You can't find them all anywhere. You'll just encounter them as you use different APIs.
    One of the most basic concepts around exceptions has to do with the difference between checked and unchecked exceptions. Any exception that extends RuntimeException is unchecked. Which means that if you call a method that throws an unchecked exception, you don't have to provide a catch block. These exceptions are usually thrown for things that could be avoided, i.e. programmer error.
    The compiler will require you to have a catch block for all checked exceptions. This means you should take steps in your code to handle them and retry the operation, such as user errors.

  • Difference in throwing and catching an exception?

    What is the difference between throwing an exception and catching an exception?

    Catching an exception is where the code you right says "Hey I am going to handle any exceptions coming this way"
    Throwing is where the method in which an exception is thrown says "I am not taking responsibility for any exceptions thrown"

  • Am trying to upgrade iPad 2 to 6.1.2 and it shows error like "Unable to verify Update" you are no longer connected to the internet. But am connect to my wi-fi. Can somebody throw some light on this.

    Am trying to upgrade iPad 2 to 6.1.2 and it shows error like "Unable to verify Update" you are no longer connected to the internet. But am connect to my wi-fi. Can somebody throw some light on this.
    ============================================================
    Throws error saying
    "Unable to Verify Update"
    iOS 6.1.2 failed verification because you are no longer connected to the internet
    ============================================================
    Can anybody please respond

    Try this and see if it resolves the issue.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.
    Then try again.

  • How to catch the error occurred in Integration Process, and then save it?

    1. how to catch the error occurred in Integration Process, and then save the detailed error message to the file?
    2. there are fault message type for inbound message interface, how to use the fault message type in IR?
    Thanks,
    Michael
    Message was edited by: Spring Tang
    inital
    Message was edited by: Spring Tang
    detailed message output
    Message was edited by: Spring Tang
    fault message type

    Hi Spring,
    If u give an exception step along with your Transformation Step, whenever some error occurs in your message mapping, this exception block wil be triggered.
    You can configure your exception block to do all exception processing that you want. This exception handling is like any other java Exceptio n Handler. You can do anything that you want in your exception handler block on the basis of your requirements.
    <i>If an exception is triggered at runtime, the system first searches for the relevant exception handler in surrounding blocks. If it does not find the correct exception handler, it continues the search in the next block in the block hierarchy.
    When the system finds the correct system handler, it stops all active steps in the block in which the exception handler is defined and then continues processing in the exception handler branch. Once the exception handler has finished processing, the process is continued after the block.
    If the system fails to find an exception handler, it terminates the integration process with an error.</i>
    Regards,
    Bhavesh

  • Basic error handling: how to catch all errors in a portion of code (and act accordingly)

    I have a portion of code in a VI that I know is likely to fail at some point (opening a file, then reading two arrays from it: the file can be absent, or contain the wrong data).
    I would like to be able to catch any errors that may occur during this procedure, and if such an error occurs launch a pre-defined action (return a default value, for instance).
    Is there a simple way to do this, in a way similar to the disabling of a portion of code with a Diagram Disable structure ?

    use the "bundle by name" function to set the individual elements of the error cluster to the values you want.
    CLA, LabVIEW Versions 2010-2013

  • Does Hibernate throw and error if the result set is above a specific #

    Does Hibernate throw and error if the result set is above a specific #
    of records?

    why do you ask?Maybe he hasn't been able to find the bug in his code yet, so he's casting further and further about for more and more esoteric explanations for what he's seeing? ;-)
    (God knows I've been there...)

  • Embed test throwing ORA-00604 and ORA- 12705 errors

    Hi,
    I've setup a JEE application and when tried to make a connection the IDE was throwing errors
    ORA-00604: error occurred at recursive SQL level 1
    ORA- 12705: invalid or unknown NLS parameter value specified
    That I fixed adding two entrances in the jdev.conf file
    AddVMOption -Duser.region=us
    AddVMOption -Duser.language=en
    Now, when I try to run an embed test throws again the same errors
    oracle.j2ee.rmi.RMIMessages EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER
    javax.ejb.EJBException: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
    ORA-12705: Cannot access NLS data files or invalid environment specified
    how can I fix this in a jdev 10.1.3.4?
    Thanks in advance.

    Hi, thanks for the reply.
    First, a question. How do I file a bug with customer support?
    Then, back to the problem.
    I have installed on a Windows Vista system the database. The windows system is set in Spanish and the database is an express edition 10.2.1015
    The JDeveloper's version where I have setup the project is 10.1.3.4.0
    The original value for the HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE/KEY_XE/NLS_LANG entrance was LATIN AMERICAN SPANISH_ECUADOR.WE8MSWIN1252, and now I have changed it to the result from querying from dual AMERICAN_AMERICA.AL32UTF8, with SELECT USERENV('LANGUAGE') FROM DUAL;
    I did this, because so I understood from the [error description|http://ora-12705.ora-code.com/]
    I also looked for a key like ORA_NLSxx in the registry, but not found
    Also checked the ORACLE_HOME and the path does lead me to the oracle installation and there is the nls folder
    But still showing the same error
    Please let me know if more info is needed.
    Thanks in advance.

  • Catching runtime errors and show message

    Hello:
    How do i catch runtimes errors and send a message back to the user to see?
    Imagine i violate a PK when writing to a database, what is the stabdard way to catch that and inform the user?
    Thanks.

    check out
    FacesContext -- addMessage()
    FacesMessages
    and the tags that dispay FacesMesssages
    <h:messages>
    <h:message>
    easy to catch an excpetion then add a FacesMessage to the context that will be displayed by the jsf message tags

  • Oracle Form 9i - How to catch for error code and error message?

    Hello:
    I'd like to catch for error code such as ORA-20001, ORA-28007 if the form is not success. I tried TOOL_ERR.CODE and TOOL_ERR.MESSAGE, but it returns 0 and no message.
    Thanks in advance,
    TD

    I got it.
    Thanks,
    TD

  • Catch any error message (dumps) in B2B and show own text

    Hi, all
    How we can catch any error messages (dumps) in the B2B?
    How we can show own text like this 'Site under construction. Please visit later...after 1 hour... '
    Denis

    Option 1(dirty approach): modify your runtimeexception jsp
    Option 2(better approach): on your load balancer (like F5 or SAP web dispatcher) configure such that all HTTP500 response codes are redirected to a hub page which has your custom text or images
    pradeep

  • Catch all error information while validating xml content with xsd schema

    Hi experts,
    I created a java mapping to validating the input xml content with xsd schema (schema validation). What I want is to catch all error message to the xml not just the first error. I used SAXParser in sapxmltoolkit.jar to do the schema validation. The below is a part of my java mapping.
    XMLReader parser = XMLReaderFactory.createXMLReader("com.sap.engine.lib.xml.parser.SAXParser");
    parser.setFeature( "http://xml.org/sax/features/validation" ,  true);
    parser.setFeature( "http://apache.org/xml/features/validation/schema" , true);
    parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");          parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",this.getClass().getClassLoader().getResourceAsStream(schema)); // schema is my schema name
    parser.setErrorHandler(new ParseErrorHandler()); // ParseErrorHandler is my own ErrorHandler which extends DefaultHandler
    parser.parse(new InputSource(new ByteArrayInputStream(sinput.getBytes())));
    // In error handler, I comment all code so as not to throw any exception
    public class ParseErrorHandler extends DefaultHandler
         public void error(SAXParseException e) throws SAXException
              // sSystem.out.println("Error" + e.getMessage());
              // throw e;
         public void fatalError(SAXParseException e)
              // throw e;
              // System.out.println("SAP Fatal Error" + e.getMessage());
    Unfortunately the program always stopped while catching the first error. Check the below log.
    com.sap.engine.lib.xml.parser.NestedSAXParserException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException:
    ERRORS :
    cvc-simple-type : information item '/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' is not valid, because it's value does not satisfy the constraints of facet 'minLength' with value '1'.
    cvc-data : information item '/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' is is not valid with respoct to the corresponding simple type definition.
    cvc-element : element information item '/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' is associated with invalid data.
    cvc-element : element information item '/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]' is not valid with respect to it's complex type definition..
    cvc-element : element information item '/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]' is not valid with respect to it's complex type definition..
    cvc-element : element information item '/:ShipNotice[1]/:Header[1]/:To[1]' is not valid with respect to it's complex type definition..
    cvc-element : element information item '/:ShipNotice[1]/:Header[1]' is not valid with respect to it's complex type definition..
    cvc-element : element information item '/:ShipNotice[1]' is not valid with respect to it's complex type definition..
    -> com.sap.engine.lib.xml.parser.ParserException:
    I tried using Xerces and JAXP to do validation, the same error happened. I have no idea on this. Does xi has its own error handler logic? Is there any body can make me get out of this?
    Thanks.

    <h6>Hi experts,
    <h6>
    <h6>I created a java mapping to validating the input xml content with xsd schema (schema validation). What I want is to catch all <h6>error message to the xml not just the first error. I used SAXParser in sapxmltoolkit.jar to do the schema validation. The below <h6>is a part of my java mapping.
    <h6>XMLReader parser = XMLReaderFactory.createXMLReader("com.sap.engine.lib.xml.parser.SAXParser");
    <h6>parser.setFeature( "http://xml.org/sax/features/validation" ,  true);
    <h6>parser.setFeature( "http://apache.org/xml/features/validation/schema" , true);
    <h6>parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");          <h6>parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",this.getClass().getClassLoader().getResourceAsStream(schema)); <h6>// schema is my schema name
    <h6>parser.setErrorHandler(new ParseErrorHandler()); // ParseErrorHandler is my own ErrorHandler which extends Default Handler
    <h6>parser.parse(new InputSource(new ByteArrayInputStream(sinput.getBytes())));
    <h6>
    <h6>// In error handler, I comment all code so as not to throw any exception
    <h6>public class ParseErrorHandler extends DefaultHandler
    <h6>{
    <h6>     public void error(SAXParseException e) throws SAXException
    <h6>     {
    <h6>          // sSystem.out.println("Error" + e.getMessage());
    <h6>          // throw e;
    <h6>     }
    <h6>
    <h6>     public void fatalError(SAXParseException e)
    <h6>     {
    <h6>          // throw e;
    <h6>          // System.out.println("SAP Fatal Error" + e.getMessage());
    <h6>
    <h6>     }
    <h6>
    <h6>}
    <h6>
    <h6>Unfortunately the program always stopped while catching the first error. Check the below log.
    <h6>
    <h6>com.sap.engine.lib.xml.parser.NestedSAXParserException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException:
    <h6>ERRORS :
    <h6>cvc-simple-type : information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' <h6>is not valid, because it's value does not satisfy the constraints of facet 'minLength' with value '1'.
    <h6>cvc-data : information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' <h6>is is not valid with respoct to the corresponding simple type definition.
    <h6>cvc-element : element information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' <h6>is associated with invalid data.
    <h6>cvc-element : element information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]' <h6>is not valid with respect to it's complex type definition..
    <h6>cvc-element : element information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]' <h6>is not valid with respect to it's complex type definition..
    <h6>cvc-element : element information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]' <h6>is not valid with respect to it's complex type definition..
    <h6>cvc-element : element information item <h6>'/:ShipNotice[1]/:Header[1]' <h6>is not valid with respect to it's complex type definition..
    <h6>cvc-element : element information item '/:ShipNotice[1]' is not valid with <h6>respect to it's complex type definition..
    <h6> -> com.sap.engine.lib.xml.parser.ParserException:
    <h6>
    <h6>
    <h6>I tried using Xerces and JAXP to do validation, the same error happened. I have no idea on this. Does xi has its own error <h6>handler logic? Is there any body can make me get out of this?
    <h6>Thanks.

  • Catching Mapping error at runtime using a udf

    Hi AlL,
    I read some blog where it was discussed.. we can catch runtime error ? Is it possible?
    how will we be able to catch the runtime error say during the mapping we got an error and we want to catch that error and log it somewhere or throw user defined exception?
    I guess at runtime all the runtime details are stored in SMPPMAP3 table. which is the field which contain the any runtime error?

    Hi,
    you cannot do it using an UDF as a uDF will only work on fields that
    are in the message
    you can throw exceptions from UDF but not catch
    to catch you can use an exception branch of a block stpe in an intgration process BPM
    Regards,
    michal

  • Unable to catch LDAPException  error code(53) in jsp on weblogic 6.1

    When I try to authenticate a user in LDAP whose account is inactivated the following error is thrown UNWILLING_TO_PERFORM in weblogic Server log.
    My JSP file couldn't to catch this exception, where as it could catch all other exception like NO_SUCH_OBJECT
    INVALID_CREDENTIALS. It throws 500 internal server error on browser which seems awkward to the user.
    Im Using basic authentication model by setting 401 status code in response.
    I have even tried catch block with Exception, but failed to catch it.
    Could Any one plz help me out.
    Exception in detail-----
    Servlet failed with Exception
    netscape.ldap.LDAPException: error result (53); Account inactivated. Contact system administrator.; DSA is unwilling to perform
    at netscape.ldap.LDAPConnection.checkMsg(LDAPConnection.java:4852)
            at netscape.ldap.LDAPConnection.internalBind(LDAPConnection.java:1757)
            at netscape.ldap.LDAPConnection.authenticate(LDAPConnection.java:1294)
            at netscape.ldap.LDAPConnection.authenticate(LDAPConnection.java:1303)
            at netscape.ldap.LDAPConnection.bind(LDAPConnection.java:1613)
            at weblogic.security.ldaprealmv2.LDAPDelegate.authenticate(LDAPDelegate.java:851)
            at weblogic.security.ldaprealmv2.LDAPRealm.authUserPassword(LDAPRealm.java:61)
            at weblogic.security.acl.AbstractListableRealm.authInternal(AbstractListableRealm.java:186)
            at weblogic.security.acl.AbstractListableRealm.authenticate(AbstractListableRealm.java:127)
            at weblogic.security.acl.AbstractListableRealm.getUser(AbstractListableRealm.java:110)
            at weblogic.security.acl.CachingRealm.authenticate(CachingRealm.java:945)
            at weblogic.security.acl.CachingRealm.getUser(CachingRealm.java:889)
            at weblogic.security.acl.Realm.authenticate(Realm.java:200)
            at weblogic.security.acl.Realm.getAuthenticatedName(Realm.java:233)
            at weblogic.security.acl.internal.Security.authenticate(Security.java:172)
            at weblogic.servlet.security.internal.SecurityModule.checkAuthenticate(SecurityModule.java:302)
            at weblogic.servlet.security.ServletAuthentication.weak(ServletAuthentication.java:318)
            at weblogic.servlet.security.internal.BasicSecurityModule.checkAuthenticateHeader(BasicSecurityModule.java:62)
            at weblogic.servlet.security.internal.ServletSecurityManager.checkAccess(ServletSecurityManager.java:118)
            at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2674)
            at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2427)
            at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:159)
            at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:140)
    --------------- nested within: ------------------
    weblogic.security.ldaprealmv2.LDAPRealmException: Account inactivated. Contact system administrator. - with nested exception:
    [netscape.ldap.LDAPException: error result (53); Account inactivated. Contact system administrator.; DSA is unwilling to perform]
            at weblogic.security.ldaprealmv2.LDAPDelegate.authenticate(LDAPDelegate.java:885)
            at weblogic.security.ldaprealmv2.LDAPRealm.authUserPassword(LDAPRealm.java:61)
            at weblogic.security.acl.AbstractListableRealm.authInternal(AbstractListableRealm.java:186)
            at weblogic.security.acl.AbstractListableRealm.authenticate(AbstractListableRealm.java:127)
            at weblogic.security.acl.AbstractListableRealm.getUser(AbstractListableRealm.java:110)
            at weblogic.security.acl.CachingRealm.authenticate(CachingRealm.java:945)
            at weblogic.security.acl.CachingRealm.getUser(CachingRealm.java:889)
            at weblogic.security.acl.Realm.authenticate(Realm.java:200)
            at weblogic.security.acl.Realm.getAuthenticatedName(Realm.java:233)
            at weblogic.security.acl.internal.Security.authenticate(Security.java:172)
            at weblogic.servlet.security.internal.SecurityModule.checkAuthenticate(SecurityModule.java:302)
            at weblogic.servlet.security.ServletAuthentication.weak(ServletAuthentication.java:318)
            at weblogic.servlet.security.internal.BasicSecurityModule.checkAuthenticateHeader(BasicSecurityModule.java:62)
            at weblogic.servlet.security.internal.ServletSecurityManager.checkAccess(ServletSecurityManager.java:118)
            at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2674)
            at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2427)
            at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:159)
            at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:140)
    ..so on

    It would worth if you take a look to the access log file, and see what error code is returning your operation. I detected that when you perform an ldapsearch using a user with expired password (with DS 5.2, explicitly passwordExpirationTime set to 19700101000000Z in my case) the command returns "ldap_search: DSA is unwilling to perform"
    jair@riscl~ $ ldapsearch -b "o=isp" -D "uid=RRJA2829,ou=people,o=affiliates,o=isp" -w met999 "uid=admin"
    ldap_search: DSA is unwilling to perform
    jair@riscl~ $ echo $?
    53And the access log shows (LDAP_SUCCESS for BIND operation):
    [23/Jun/2009:15:16:14 -0500] conn=1847 op=-1 msgId=-1 - fd=48 slot=48 LDAP connection from 127.0.0.1 to 127.0.0.1
    [23/Jun/2009:15:16:14 -0500] conn=1847 op=0 msgId=1 - BIND dn="uid=RRJA2829,ou=people,o=affiliates,o=isp" method=128 version=3
    [23/Jun/2009:15:16:14 -0500] conn=1847 op=0 msgId=1 - RESULT err=0 tag=97 nentries=0 etime=0 dn="uid=rrja2829,ou=people,o=affiliates,o=isp"
    [23/Jun/2009:15:16:14 -0500] conn=1847 op=1 msgId=2 - need new password
    [23/Jun/2009:15:16:14 -0500] conn=1847 op=1 msgId=2 - RESULT err=53 tag=101 nentries=0 etime=0
    [23/Jun/2009:15:16:14 -0500] conn=1847 op=2 msgId=3 - UNBIND
    [23/Jun/2009:15:16:14 -0500] conn=1847 op=2 msgId=-1 - closing - U1
    [23/Jun/2009:15:16:15 -0500] conn=1847 op=-1 msgId=-1 - closed.So, it is possible that your code doesn't catch the exception because the bind operation is returning code 0 (LDAP_SUCCESS) and for some other reason weblogic is receiving a second code 53 which is thrown by the server and not catched by your code, I really don't know if it is possible, is just what comes to my mind right now.
    I also made a test with java using the same user with expired password and couldn't catch any exception like in your case
    import java.util.Hashtable;
    import javax.naming.directory.*;*
    *import javax.naming.ldap.*;
    import javax.naming.*;
    public class Password {
       public static void main (String args[]) {
          LdapContext ctx = null;
          String userid = "uid=RRJA2829,ou=people,o=affiliates,o=isp";
          String passwd = "met999";
          try {
             Hashtable env = new Hashtable();
             env.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
             env.put("java.naming.provider.url", "ldap://riscl:389/");
             env.put("java.naming.security.principal", userid);
             env.put("java.naming.security.credentials", passwd);
             ctx = new InitialLdapContext(env, null);
          } catch (AuthenticationException e) {
                System.out.println("=> "  +e.getMessage()+  " <=");
          } catch (NamingException ne) {
             System.out.println("=> "  +ne.getMessage()+  " <=");
    }and the logs showed:
    [23/Jun/2009:15:32:41 -0500] conn=43 op=-1 msgId=-1 - fd=52 slot=52 LDAP connection from 127.0.0.1 to 127.0.0.1
    [23/Jun/2009:15:32:41 -0500] conn=43 op=0 msgId=1 - BIND dn="uid=RRJA2829,ou=people,o=affiliates,o=isp" method=128 version=3
    [23/Jun/2009:15:32:41 -0500] conn=43 op=0 msgId=1 - RESULT err=0 tag=97 nentries=0 etime=0 dn="uid=rrja2829,ou=people,o=affiliates,o=isp"
    [23/Jun/2009:15:32:42 -0500] conn=43 op=-1 msgId=-1 - closing - B1
    [23/Jun/2009:15:32:42 -0500] conn=43 op=-1 msgId=-1 - closed.but in this case LDAP is not returning the code 53 "UNWILLING TO PERFORM" to java app in the way it did to ldapsearch.
    Hope it helps.
    BR,
    jairsinho

  • With out try and catch

    with out any try and catch is exception handling is possible in java when doing manupulation with database.
    assume mydatabase is oracle,if i am going to insert a record of a primarykey field, which is already existing.i don't want to put with in try and catch.This is my case.if u have the answer for this please mail me.
    thanks
    rajan

    assume mydatabase is oracle,if i am going to insert a
    record of a primarykey field, which is already existing.
    i don't want to put with in try and catch.why not? i thought the fact that checked exceptions get thrown from methods is a good thing, since you're forced either to deal with the fault immediately, or throw to the next level up, possibly transformed into an application-level exception. if methods were to simply return method-specific error codes, nothing forces anything in the program to deal with errors in a reasonable manner. not that exceptions force sensible handling of the fault--but they do force recognition of the fault.
    what alternative do you desire?
    --p

Maybe you are looking for

  • Question about using a USA itunes account in UK

    So can I do this? I live in the UK, so can I use an american account with no credit card on but has credit to download albums?

  • WPC- Cannot insert an I-view :- Portal Runtime Error

    Hi All when we try to include an iview through Web Page Composer at the time of view/publish we been geting a Portal Error..below is the error and the log file info.. Portal Runtime Error An exception occurred while processing your request Exception

  • Make fields only editable by certain useres

    hello, i have created several authorization schemes. In the "Security" section of a text field i can choose these so that the item is only displayed for authorized users. However, I would like everybody to see the text field, but only authorized user

  • Mail.app suddenly stops moving Junk mail

    I leave Mail.app running at home, because its spam filtering is the only thing that makes reading my mail on my iPhone bearable, since the iPhone does not have any spam capabilities of its own. But a couple of days ago, Mail.app just stopped moving m

  • ISE and AAA configuration

    Hi Guys, I am using ISE only one server as primary and as cisco says it has functionality of (ACS+ NAC). I  want to enable AAA services on the  ISE box rightnow. I used the ACS earlier and want to configure the same functions on it. Authentication of