Exception handling in PocketBuilder

When a runtime error occurs in a PocketBuilder application, unless that error is trapped, a single application event (SystemError) fires to handle the error no matter where in the application it occurred. Although some errors can be handled in the system error event, catching the error closer to its source increases the likelihood of recovery from the error condition.

You can use exception-handling classes and syntax to handle context-sensitive errors in PocketBuilder applications. This means that you can deal with errors close to their source by embedding error-handling code anywhere in your application. Well designed exception-handling code can give application users a better chance to recover from error conditions and run the application without interruption.

Exception handling allows you to design an application that can recover from exceptional conditions and continue execution. Any exceptions that you do not catch are handled by the runtime system and can result in the termination of the application.

Exception handling can be found in such object-oriented languages as Java and C++. The implementation of exception handling in PocketBuilder is similar to the implementation in Java. In PocketBuilder, the TRY, CATCH, FINALLY, THROW, and THROWS reserved words are used for exception handling. There are also several PocketBuilder objects that descend from the Throwable object.