# Use the ASPError Object

## Overview
The **ASPError** object in G3Pix AxonASP provides structured, detailed information about the most recent error that occurred during script execution. It is primarily used within custom error-handling pages to display or log technical data such as the error number, source file, and line number where the fault occurred.

## Prerequisites
- **Server.GetLastError**: You must call the `Server.GetLastError` method to retrieve a reference to the **ASPError** object.
- **Custom Error Pages**: To use this object effectively, configure your application to redirect to a custom error script (e.g., via `web.config`).

## How it Works
When a runtime or compilation error occurs in G3Pix AxonASP, the engine captures the state of the error. This information is preserved until it is explicitly retrieved. 
- **Read-Only**: All properties of the **ASPError** object are read-only.
- **Scope**: The object only contains information about the *last* error that occurred in the current request context.

## API Reference

### Properties
- **ASPCode**: Returns an **Integer** representing the error code generated by the AxonASP engine.
- **ASPDescription**: Returns a **String** containing a detailed description of the error if it is an ASP-specific error.
- **Category**: Returns a **String** indicating the source of the error (e.g., "VBScript runtime", "AxonASP", or "ASP").
- **Column**: Returns an **Integer** specifying the character position within the line where the error occurred.
- **Description**: Returns a **String** containing a short description of the error.
- **File**: Returns a **String** containing the virtual path of the file that generated the error.
- **HelpContext**: Returns an **Integer** specifying the help context ID for the error (usually 0).
- **HelpFile**: Returns a **String** containing the path to a help file if available.
- **Line**: Returns an **Integer** specifying the line number in the source file where the error occurred.
- **Number**: Returns an **Integer** representing the standard VBScript error number.
- **Source**: Returns a **String** containing the source code of the line that caused the error.

## Code Example
The following example demonstrates how to extract error details in a custom error handler page.

```asp
<%
Dim objErr
Set objErr = Server.GetLastError()

Response.Write "<h1>An Error Occurred</h1>"
Response.Write "<b>Category:</b> " & objErr.Category & "<br>"
Response.Write "<b>Number:</b> " & objErr.Number & "<br>"
Response.Write "<b>Description:</b> " & objErr.Description & "<br>"
Response.Write "<b>File:</b> " & objErr.File & "<br>"
Response.Write "<b>Line:</b> " & objErr.Line & "<br>"

Set objErr = Nothing
%>
```

## Remarks
- **Security**: In production environments, avoid displaying the full details of the **ASPError** object to end-users, as it may reveal sensitive system information.
- **Logging**: Use the properties of this object to populate database logs or system event logs for administrative review.
- **Persistence**: The error information is only available for the duration of the request that triggered the error or the subsequent error handler.
