[ 
https://issues.apache.org/jira/browse/BSF-29?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Brett Randall updated BSF-29:
-----------------------------

    Description: 
If a ScriptException is constructed via ScriptException(Exception e), the 
resulting exception always returns the String "null" for getMessage().  This is 
against the normal chained-exception convention of:

     * Constructs a new throwable with the specified cause and a detail
     * message of <tt>(cause==null ? null : cause.toString())</tt> (which
     * typically contains the class and detail message of <tt>cause</tt>).

(reference Javadoc for java.lang.Throwable).

The following unit test, added to BSF ScriptExceptionTest, fails against BSF 
3.0 on JDK1.4, but passes against JDK6/JSR-223:

    public void testException5(){
        ScriptException ex = new ScriptException(new Exception("exception 
message"));
        try {
                throw ex;
        } catch (ScriptException e) {
                assertEquals("java.lang.Exception: exception message", 
ex.getMessage());
        }
    }

For BSF 3.0, ex.getMessage() returns String "null".

API clients which wrap/chain detailed error messages, perhaps containing 
line/column and other details of the nature of the error in the script engine, 
will find these errors missing in the top-level exception and only accessible 
via getCause().


  was:
If a ScriptException is constructed via ScriptException(Exception e), the 
resulting exception always returns null for getMessage().  This is against the 
normal chained-exception convention of:

     * Constructs a new throwable with the specified cause and a detail
     * message of <tt>(cause==null ? null : cause.toString())</tt> (which
     * typically contains the class and detail message of <tt>cause</tt>).

(reference Javadoc for java.lang.Throwable).

The following unit test, added to BSF ScriptExceptionTest, fails against BSF 
3.0 on JDK1.4, but passes against JDK6/JSR-223:

    public void testException5(){
        ScriptException ex = new ScriptException(new Exception("exception 
message"));
        try {
                throw ex;
        } catch (ScriptException e) {
                assertEquals("java.lang.Exception: exception message", 
ex.getMessage());
        }
    }

For BSF 3.0, ex.getMessage() returns null.

API clients which wrap/chain detailed error messages, perhaps containing 
line/column and other details of the nature of the error in the script engine, 
will find these errors missing in the top-level exception and only accessible 
via getCause().


        Summary: ScriptException constructed via chained constructor 
ScriptException(Exception) always returns String "null" for getMessage()  (was: 
ScriptException constructed via chained constructor ScriptException(Exception) 
always returns null for getMessage())

> ScriptException constructed via chained constructor 
> ScriptException(Exception) always returns String "null" for getMessage()
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: BSF-29
>                 URL: https://issues.apache.org/jira/browse/BSF-29
>             Project: BSF
>          Issue Type: Bug
>    Affects Versions: BSF-3.0
>            Reporter: Brett Randall
>            Priority: Minor
>
> If a ScriptException is constructed via ScriptException(Exception e), the 
> resulting exception always returns the String "null" for getMessage().  This 
> is against the normal chained-exception convention of:
>      * Constructs a new throwable with the specified cause and a detail
>      * message of <tt>(cause==null ? null : cause.toString())</tt> (which
>      * typically contains the class and detail message of <tt>cause</tt>).
> (reference Javadoc for java.lang.Throwable).
> The following unit test, added to BSF ScriptExceptionTest, fails against BSF 
> 3.0 on JDK1.4, but passes against JDK6/JSR-223:
>     public void testException5(){
>       ScriptException ex = new ScriptException(new Exception("exception 
> message"));
>       try {
>               throw ex;
>       } catch (ScriptException e) {
>               assertEquals("java.lang.Exception: exception message", 
> ex.getMessage());
>       }
>     }
> For BSF 3.0, ex.getMessage() returns String "null".
> API clients which wrap/chain detailed error messages, perhaps containing 
> line/column and other details of the nature of the error in the script 
> engine, will find these errors missing in the top-level exception and only 
> accessible via getCause().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: bsf-dev-unsubscr...@jakarta.apache.org
For additional commands, e-mail: bsf-dev-h...@jakarta.apache.org

Reply via email to