Basics of exception handling
Exceptions are objects that are thrown in the event of some
exceptional (or unexpected) condition or error and are used to describe
the condition or error encountered. Standard errors, such as null object
references and division by zero, are typically thrown by the runtime
system. These types of errors could occur anywhere in an application and
you can include catch clauses in any executable script to try to recover
from these errors.
User-defined exceptions
There are also exceptional conditions that do not immediately
result in runtime errors. These exceptions typically occur during
execution of a function or a user-event script. To signal these
exceptions, you create user objects that inherit from the PowerScript
Exception class. You can associate a user-defined exception with a
function or user event in the prototype for the method.
For example, a user-defined exception might be created to indicate
that a file cannot be found. You could declare this exception in the
prototype for a function that is supposed to open the file. To catch
this condition, you must instantiate the user-defined exception object
and then throw the exception instance in the method script.