Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > XML applications > Use the XML API to perform operations > Use a message handler and managing exceptions
Manage exceptions
Various exceptions might occur. Unless otherwise indicated, all exceptions extend RuntimeException and thus are unchecked.
Procedure
- Manage XProcessException.
This exception occurs when the processor finds a nonrecoverable error when preparing or executing an expression, query, or stylesheet as described in the specifications for each language.
If there are multiple errors at prepare time, the processor attempts to report all of the errors and only generates an XProcessException at the end of preparation or if it reaches a point where it cannot continue. At execution time, however, the first error results in an XProcessException and the end of execution.
In general, XProcessExceptions should not occur if the expression, query, or stylesheet is syntactically and semantically valid and also valid for the types of input documents that it is meant to process.
An XProcessException also occurs for an XSLT message instruction where the terminate attribute evaluates to "yes."
This is the default behavior for handling processing errors and other messages. Applications can register an implementation of the XMessageHandler interface at prepare time or execution time to modify the default behavior.
- Manage an XViewException.
This exception is raised for incorrect use of the XML API itself such as calling one of the XNodeView methods on an item that is atomic.
See the API documentation for more information about when this exception can occur.
- Manage a NullPointerException.
This exception is raised when a null value is passed to an API method where null is not allowed, such as passing a null prefix or namespace to the XStaticContext declareNamespace method.
See the XML API documentation for more information about when this exception can occur.
- Manage an IllegalArgumentException.
This exception is raised when an invalid value is passed to an API method, such as calling the XStaticContext setXPathCompatibilityMode method with a value other than one of the predefined settings.
See the XML API documentation for more information about when this exception can occur.
- Manage exceptions generated by XFactory.newInstance.
The newInstance method on the XFactory class loads the XFactory implementation class and creates a new instance; therefore, any of the following checked exceptions might occur:
- ClassNotFoundException
- IllegalAccessException
- InstantiationException
These exceptions would likely result if there is a classpath problem or a Java security issue.
Use a message handler
XPath 2.0 errors
XQuery errors
XSLT 2.0 errors