Difference between revisions of "Error and Exception Handling"

From Recital Documentation Wiki
Jump to: navigation, search
(Error Information Functions)
(Error Information Functions)
Line 55: Line 55:
 
character = message()
 
character = message()
 
</pre>
 
</pre>
 
  
 
* [[MESSAGE()|message(1)]] - Returns the line of code which caused the error
 
* [[MESSAGE()|message(1)]] - Returns the line of code which caused the error

Revision as of 10:48, 15 December 2009

Error and Exception Handling

When an error occurs in a running application, Recital will stop execution, display an error message and create an error.mem file, unless an alternative error handling procedure has been specified.

Error.mem

The error.mem file includes the following information:

  • The Recital Product version, release, platform and compile date information
  • System information, such as maximum file size and maximum process stack
  • Recital License information
  • User and Node names and process ID
  • The error number
  • The error message
  • The program line
  • The program line number
  • A stack trace of the programs and procedures called
  • A list of all active public and private memory variables and classes
  • Status of open tables, indexes and current records.
  • Settings listing as per LIST STATUS

SET ERRORVERSION

The error.mem file will be named error.mem and will be overwritten by subsequent errors unless set errorversion is on. If set errorversion is on, multiple numbered error.mem files are created with the following naming format:

error0001.mem

error0002.mem

error0003.mem

DB_ERRORDIR

The error.mem file(s) will be created in the directory that is current when the error occurs unless the DB_ERRORDIR environment variable is set. If set, DB_ERRORDIR points to a directory in which the error.mem file(s) will be created.

The ON ERROR statement

Alternative error handling procedures can be specified using the on error command. When there is an active on error setting, no error.mem file will be created and program execution willl not be halted. It is now up to the on error error handler to trap the information required in order to trace the error and to take appropriate action based on the error that has occurred.

Note: The save error command allows for the creation of an equivalent of the error.mem file.

Error Information Functions

Several functions are available to give information about errors:

  • errno() - Returns operating system error number
numeric = errno()
  • error() - Returns Recital error number
numeric = error()
character = message()
  • message(1) - Returns the line of code which caused the error
character = message(1)
  • procline() - Returns currently executing procedure line number
numeric = procline()
  • procname() - Returns currently executing procedure name
character = procname()

It is important to note that the procline() and procname() functions return information about the currently executing procedure. If these functions are called from within the error handling procedure, they will give information based on the error handling procedure itself and not the procedure in which the error occurred. They should, therefore, be specified as parameters to the error handler, e.g.

on error do MyErrProc with procname(), procline()

The TRY...CATCH Statement

Summary