CRE Programmer's Guide

CRE Services
Common Run-Time Environment (CRE) Programmer’s Guide528146-004
2-48
Errors in Program Logic
Using ARMTRAP
Writing messages to standard log
Handling errors in TNS CRE-supported languages
In the Guardian environment, the TNS CRE performs the tasks described in this
subsection. In the OSS environment on G-series systems, the TNS CRE does not
process traps or exceptions. Traps are a feature of the Guardian environment. Signals
provide an analogous capability in the OSS environment. See the
Open System
Services Programmer’s Guide for more information about signals.
In the OSS environment on G-series systems, the TNS CRE reports only non-
recoverable errors (for example, a corrupted run-time environment). See Reporting
CRE Errors in the OSS Environment on page 2-54 for more details.
Errors in Program Logic
An error in your program that is not caused by a trap (except for an arithmetic overflow
trap) and does not corrupt the CRE’s data or a run-time library’s data is considered a
program logic error. The following are examples of program logic errors:
Arithmetic overflow
Insufficient resources; for example, out of heap space
Invalid actual parameter passed to a standard function
Invalid result from a standard function
I/O error when accessing a file
Case statement in which the case selector does not match any case alternative,
including an “otherwise” alternative
Program logic errors are processed by the run-time library for the routine in which the
error occurred.
Error Handling and Math Standard Functions
When a CRE (or RTL) math function detects an invalid parameter or an error in
computing the function’s value, the function causes an arithmetic fault to occur when
the math function returns to its caller.
In the TNS environment, if your program invoked the math function using a standard C,
COBOL, or FORTRAN construct, the run-time library for the routine that invoked the
math function determines your program’s behavior.
If you invoke a standard math function from a TAL routine in the TNS environment,
your TAL routine can determine the effect of the error by setting or resetting the trap-
enable bit of the TNS environment register. Ensure that the trap-enable bit of the TNS
environment register is set according to the needs of your program before the program
calls a math function.