Java Exceptions
When you work with Java from within Magic xpa and your program causes a Java runtime error, it is important that you catch the Java exception from your Magic xpa program and supply the end user with the basic information regarding the source of the problem.
If there is an illegal operation in Java, an exception will occur. However, the end user will not see the exception unless you handle it.
Magic xpa enables you to handle Java exceptions with the help of two internal functions:
· The JavaExceptionOccurred() function informs you that an exception occurred during the last Java operation.
· The JavaException() function returns a reference to the last exception that occurred by a Java operation.
Magic xpa encloses every Java operation in a Try/Catch block. It is your responsibility to handle any exception that may occur. Since the Magic xpa Java exception functions refer to the last exception that occurred, it is important to check for exceptions after every relevant operation.
Since this function returns a Java object, you can use it as a part of an expression, as you would use with other Java objects.
For example, you can use the Verify operation with JavaException().ToString() in order to show the exception message.
This function is not available in Web Client tasks.