Purpose
Returns a numeric code, representing the current error. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
Err()
Return Value
Integer
Description
The Err() function returns the numeric code indicating which error occurred most recently.
By default, a MapBasic program which generates an error will display an error message and then halt. However, by issuing an OnError statement, a program can set up an error handling routine to respond to error conditions. Once an error handling routine is specified, MapBasic jumps to that routine automatically in the event of an error. The error handling routine can then call the Err() function to determine which error occurred.
The Err() function can only return error codes while within the error handler. Once the program issues a Resume statement to return from the error handling routine, the error condition is reset. This means that if you call the Err() function outside of the error handling routine, it returns zero.
Some statement and function descriptions within this document contain an Error Conditions heading (just before the Example heading), listing error codes related to that statement or function. However, not all error codes are identified in the Error Conditions heading.
Some MapBasic error codes are only generated under narrowly-defined, specific circumstances; for example, the ERR_INVALID_CHANNEL (696) error is only generated by DDE-related functions or statements. If a statement might generate such an "unusual" error, the discussion for that statement will identify the error under the Error Conditions heading.
However, other MapBasic errors are "generic", and might be generated under a variety of broadly-defined circumstances. For example, many functions, such as Area() function and ObjectInfo() function, take an Object expression as a parameter. Any such function will generate the ERR_FCN_OBJ_FETCH_FAILED (650) error if you pass an expression of the form tablename.obj as a parameter, when the current row from that table has no associated object. In other words, any function which takes an Object parameter might generate the ERR_FCN_OBJ_FETCH_FAILED (650) error. Since the ERR_FCN_OBJ_FETCH_FAILED (650) error can occur in so many different places, individual functions do not explicitly identify the error.
Similarly, there are two math errors-ERR_FP_MATH_LIB_DOMAIN (911) and ERR_FP_MATH_LIB_RANGE (912)-which can occur as a result of an invalid numeric parameter. These errors might be generated by calls to any of the following functions: Acos() function, Asin() function, Atn() function, Cos() function, Exp() function, Log() function, Sin() function, Sqr() function, or Tan() function.
The complete list of potential MapBasic error codes is included in the file ERRORS.DOC.
See Also:
Error statement, Error$() function, OnError statement