Exception handling in PowerBuilder
When a runtime error occurs
in a PowerBuilder application, unless that error is trapped, a single
application event (SystemError) fires to handle the error no matter
where in the application the error happened. 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 PowerBuilder 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.
PowerBuilder clients can catch exceptions thrown from application
server components and recover from them. Components developed with PowerBuilder
can also define and throw their own exception types, making them
more consistent with other server component types like Java.
Exception handling can be found in such object-oriented languages
as Java and C++. The implementation for PowerBuilder
is similar to the implementation of exception handling in Java.
In PowerBuilder, the TRY, CATCH, FINALLY, THROW,
and THROWS reserved words are used for exception
handling. There are also several PowerBuilder objects that descend
from the Throwable object.