The following topics show all the dBASE Plus error messages. Choose a topic to display the messages and their corresponding numbers alphabetically or numerically.

Error Messages - Alphabetical List

Error Messages - Numeric List

Trapping Errors

You can use the ON ERROR command to designate a subroutine as an error handler. This subroutine is automatically executed when an error condition occurs during runtime. The subroutine can use the following functions to trap errors:

 ERROR( ) returns a dBASE error number.

 MESSAGE( ) returns a dBASE error message.

 DBERROR( ) returns a BDEerror number.

 DBMESSAGE( ) returns a BDE error message.

 SQLERROR( ) returns a server error number.

 SQLMESSAGE( ) returns a server error message.

 LINENO( ) returns the number of the line at which the error occurred.

 PROGRAM( ) returns the name of the program, procedure, or user-defined function in which the error occurred.

The error-handler subroutine can use these returned values to make branching decisions or provide information to the user.

ON NETERROR is similar to ON ERROR, except that ON ERROR responds to all run-time errors regardless of whether they're multiuser-specific. You can use ON ERROR to handle both single-user and multiuser errors, or you can use ON NETERROR to handle just multiuser errors. If you issue both ON ERROR and ON NETERROR, then ON ERROR responds to just single-user errors, leaving ON NETERROR to respond to multiuser errors.

The CERROR( ) function returns the number of an error that occurs at compile time.

 

Every dBASE error has, internally, an associated error level which can be one of the following:

Information
Warning
Error
Execution
Severe
Internal
NetError

 

The error level is used by the built-in error handler to determine how to process the error.

For example, most errors are assigned the 'Error' level. This means that the built-in error handler will perform the normal error handling currently in effect for dBASE or for a running application. By default this would be to display an error dialog.

A small number of errors are assigned the 'Severe' or 'Internal' error levels which are used mainly for errors that are unrecoverable and which lead to dBASE or an application shutting down.

Two errors are assigned the 'Execution' error level. They are:

 

The 'Execution' error level indicates to the built-in error handler that the error is a kind of warning and should not be surfaced to the user or running program unless SET TALK is ON or an ON ERROR handler is enabled.

Errors assigned the 'Warning' error level are handled in the same way. Whether or not an illegal value or an out of range substr() call is serious for a program depends on the details of the program code.  With SET TALK ON you are telling dBASE to inform you of all the output generated by the executing code including any warnings.

 

If you setup an ON ERROR handler you are taking responsibility for all the error reporting via your custom error handler.  You can code your error handler either to report warnings as errors or to ignore them or to simply log them without reporting them via the error dialog.

Warning level and Execution level errors do not appear to trigger try...catch handlers.

If you write your ON ERROR handler as follows you can prevent Out of Range and Illegal Value errors from being displayed:

on error globalErrorTrap(program(), lineno(), error(), message())

The ON ERROR handler can then display an error message and terminate the application, like this:

function globalErrorTrap(cProg, nLineno, nError, cMsg)

   if nError = 158 or nError = 164

      // warnings - just return

   return

   endif

   local c

   #define CHAR_CR chr(13)

   c =             cMsg  + CHAR_CR + CHAR_CR + ;

                     "In: "    + cProg + CHAR_CR + ;

      "Line: "  + nLineno + CHAR_CR + CHAR_CR + ;

      "If this error persists, contact program vendor."

   msgbox(c, "Unexpected Application Error [" + nError +"]", 16)

   quit

The bottom line is that for the Out of Range error that you encountered, you can handle it however you want to within your error handler.