Condividi tramite


AERROR( ) Function

Creates a variable array containing information about the most recent Visual FoxPro, OLE, or ODBC error.

AERROR(ArrayName)

Return Values

Numeric

Parameters

  • ArrayName
    Specifies the name of the array that AERROR( ) creates.

Remarks

AERROR( ) creates an array with seven columns and returns the number of rows in the array. The type of error that occurred determines the number of rows in the array.

The following table describes the contents of each element when a Visual FoxPro error occurs. When a Visual FoxPro error occurs, the array contains one row.

Element number Description
1 Numeric. The number of the error. Identical to the value returned by ERROR( ).
2 Character. The text of the error message. Identical to the value returned by MESSAGE( ).
3 The null value. However, if the error has an additional error parameter, contains the text of the error parameter. Almost identical to the value returned by SYS(2018), the difference being that AERROR( ) returns mixed case but SYS(2018) returns all uppercase.
4 The null value. However, as appropriate, contains the number of the work area in which the error occurred.
5 The null value. However, if a trigger failed (error 1539), contains one of the following numeric values:1 – Insert trigger failed.2 – Update trigger failed.3 – Delete trigger failed.
6 The null value.
7 The null value.

The following table describes the contents of each element when OLE errors numbered 1427 or 1429 occur. When these OLE errors occur, the array contains one row.

Element number Description
1 Numeric. Contains 1427 or 1429.
2 Character. The text of the Visual FoxPro error message.
3 Character. The text of the OLE error message.
4 Character. The application name (for example, Microsoft Excel).
5 The null value or Character. Contains the name of the application's Help file where more information about the error can be found if the information is available from the application; otherwise contains the null value.
6 The null value or Character. Contains the Help context ID for the appropriate Help topic if the information is available from the application; otherwise contains the null value.
7 Numeric. An OLE 2.0 exception number.

The following table describes the contents of each element when an ODBC error numbered 1526 occurs. When an ODBC error occurs, the array contains two or more rows; one row for each ODBC error.

Element number Description
1 Numeric. Contains 1526.
2 Character. The text of the error message.
3 Character. The text of the ODBC error message.
4 Character. The current ODBC SQL state.
5 Numeric. The error number from the ODBC data source.
6 Numeric. The ODBC connection handle.
7 The null value.

Example

The following example uses ON ERROR to specify an error handling routine named errhand. An error is generated by issuing a misspelled command (BRWS). The errhand error handling routine uses AERROR( ) to create an array containing error information, and this information is then displayed.

ON ERROR DO errhand     && errhand is the error handler procedure

BRWS  && Causes a syntax error
ON ERROR  && Restore system error handler

PROCEDURE errhand
   = AERROR(aErrorArray)  && Data from most recent error
   CLEAR
   ? 'The error provided the following information'  && Display message
   FOR n = 1 TO 7  && Display all elements of the array
      ? aErrorArray(n)
   ENDFOR

See Also

COMRETURNERROR( ) | CREATE TRIGGER | ERROR | ERROR( ) | MESSAGE( ) | ON ERROR | SYS(2018) – Error Message Parameter | Error Messages A-Z | Error Messages by Number