Exceptions and error handling
In the classes provided in the SOM run-time library (that is, SOMClass,
SOMObject, and SOMClassMgr), error handling is performed by a
user-replaceable procedure, pointed to by the global variable SOMError,
that produces an error message and an error code and, if appropriate ate,
ends the process where the error occurred. (Chapter 5 describes how to customize
the error handling procedure.)
Each error is assigned a unique integer error code. Errors are grouped into
three categories, based on the last digit of the error code:
This category of error represents
an informational event. The event is considered normal and can be ignored
or logged at the user's discretion. Error codes having a last digit of 2
belong to this category.
SOM_Warn
This
category of error represents an unusual condition that is not a normal event,
but is not severe enough to require program termination. Error codes having
a last digit of 1 belong to this category.
SOM_Fatal
This category of error represents a condition
that should not occur or that would result in loss of system integrity if
processing were allowed to continue. In the default error handling procedure,
these errors cause the termination of the process in which they occur. Error
codes having a last digit of 9 belong to this category.
The various codes for all errors detected by SOM are listed in Appendix
A, "Customer Support and Error Codes."
When errors are encountered in client programs or user defined-classes,
the following two macros can be used to invoke the error-handling procedure:
SOM_Error
The SOM_Error macro takes
an error code as its only argument and invokes the SOM error handling procedure
(pointed to by the global variable SOMError) to handle the error.
The default error handling procedure prints a message that includes the
error code, the name of the source file, and the line number where the macro
was invoked. If the last digit of the error code indicates a serious error
(of category SOM_Fatal), the process causing the error is terminated.
(Chapter 5 describes how to customize the error handling procedure.)
SOM_Test
The SOM_Test macro takes a boolean expression
as an argument. If the expression is TRUE (nonzero) and the SOM_AssertLevel
is greater than zero, then an informational message is output. If the
expression is FALSE (zero), an error message is produced and the program
is terminated.
See the System Object Model Programming Reference for more information
on a specific macro.
Other classes provided by the SOMobjects Toolkit (including those in the
Persistence, Replication, DSOM, and Interface Repository frameworks, and
the utility classes and metaclasses) handle errors differently. Rather than
invoking SOMError with an error code, their methods return exceptions
via the (Environment *) inout parameter required by these methods.
The following sections describe the exception declarations, the standard
exceptions, and how to set and get exception information in an Environment
structure.
[Back: Checking the validity of method calls]
[Next: Exception declarations]