Java director exception handling improvements
When a director method throws an exception and it is caught by DirectorException and passed back to Java using DirectorException::raiseJavaException, the Java stack trace now contains the original source line that threw the exception. Director exception handling code improved slightly to add some missing ExceptionClear calls before calling JNI code.
This commit is contained in:
parent
7d6808daab
commit
7aa28e37ec
7 changed files with 74 additions and 44 deletions
|
|
@ -127,19 +127,28 @@ public class java_director_exception_feature_runme {
|
|||
try { b.genericpong(1); fail("No exception thrown in genericpong(1)"); }
|
||||
catch (MyJavaException1 e) {
|
||||
failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP1.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
StackTraceElement[] st = e.getStackTrace();
|
||||
failif( st.length != 5, "Stack length is only " + st.length);
|
||||
failif( ! st[0].toString().startsWith("java_director_exception_feature_MyFooDirectorImpl.genericpong(java_director_exception_feature_runme.java:"), "Incorrect top of stack: " + st[0]);
|
||||
}
|
||||
try { b.genericpong(2); fail("No exception thrown in genericpong(2)");}
|
||||
catch (NewCheckedException e) {
|
||||
failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP2.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
StackTraceElement[] st = e.getStackTrace();
|
||||
failif( st.length != 5, "Stack length is only " + st.length);
|
||||
failif( ! st[0].toString().startsWith("java_director_exception_feature_MyFooDirectorImpl.genericpong(java_director_exception_feature_runme.java:"), "Incorrect top of stack: " + st[0]);
|
||||
}
|
||||
try { b.genericpong(3); fail("No exception thrown in genericpong(3)");}
|
||||
catch (NewUncheckedException e) {
|
||||
failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP3.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
StackTraceElement[] st = e.getStackTrace();
|
||||
failif( st.length != 5, "Stack length is only " + st.length);
|
||||
failif( ! st[0].toString().startsWith("java_director_exception_feature_MyFooDirectorImpl.genericpong(java_director_exception_feature_runme.java:"), "Incorrect top of stack: " + st[0]);
|
||||
}
|
||||
try { b.genericpong(4); fail("No exception thrown in genericpong(4)");}
|
||||
catch (RuntimeException e) {
|
||||
failif ( e.getClass() != RuntimeException.class, "Exception " + e + " is not exactly RumtimeException");
|
||||
failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP4.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
failif ( e.getClass() != RuntimeException.class, "Exception " + e + " is not exactly RuntimeException");
|
||||
failif( ! "Unspecified DirectorException message".equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue