UDI has a very robust error detection/reporting mechanism. For many common programming errors, the UDI messages are so detailed that the user does not need to resort to a source code debugger.
When UDI detects an error,
one or more messages are printed and an error is signaled.
The error signal can be caught in the user's program with the
ERRORCATCH", ON_ERROR", and ENDCATCH" macros.
Normally, only the code between theSPMquotERRORCATCH"
- Normal processing code -SPMquotON_ERROR"
- Error processing code -ENDCATCH"
SPMquotERRORCATCH" and SPMquotON_ERROR"
keywords is executed. If UDI signals an error, however, the code between
the SPMquotON_ERROR" and SPMquotENDCATCH" keywords is executed. Note that
SPMquotON_ERROR" is optional; if an error is signaled and it is absent,
execution
resumes after the SPMquotENDCATCH".
The example program in Figure 2.2 will not run correctly
because the element type of result"
is not the same as the element type of vector1" and SPMquotvector2".
When the program is run, we get the following output:
% example vmul: the data type of 'result' must be equal to real. OOPS! Detected an error %If the user has not used the
SPMquotERRORCATCH" mechanism and UDI signals an
error, the abort()" routine is called which causes a core dump (on Unix
systems) to aid in debugging. The user can specify a different
routine by calling error_handler(fptr)" where fptr is a pointer
to a function returning an integer (int (*fptr)()"). Note that the
error handling routine should eventually call exit()" since it is not
possible to recover from most UDI errors.