> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zentien.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Handled Error Capture

> Use ErrorLogger.log() to capture errors you catch explicitly in Apex.

## Overview

For errors you catch in a try/catch block, use `ErrorLogger.log()` to send them to Zentien instantly via Platform Events. There is no email delay — errors appear in your dashboard in real time.

## Basic usage

```apex theme={null}
try {
    // your code here
} catch (Exception e) {
    ErrorLogger.log(e, 'YourClassName', 'yourMethodName');
}
```

## Method signatures

```apex theme={null}
// Log an exception with class and method context
ErrorLogger.log(Exception e, String className, String methodName)

// Log with a specific severity level
ErrorLogger.log(Exception e, String className, String methodName, String severity)

// Log with severity and a related record ID
ErrorLogger.log(Exception e, String className, String methodName, String severity, String recordId)
```

## Severity levels

| Level      | When to use                                   |
| ---------- | --------------------------------------------- |
| `INFO`     | Non-critical issues, handled gracefully       |
| `WARNING`  | Unexpected but recoverable                    |
| `ERROR`    | Standard errors that need attention (default) |
| `CRITICAL` | Severe failures affecting core functionality  |

## Examples

**Basic exception logging:**

```apex theme={null}
try {
    Account acc = [SELECT Id FROM Account WHERE Id = :recordId];
    update acc;
} catch (Exception e) {
    ErrorLogger.log(e, 'AccountService', 'updateAccount');
}
```

**With severity:**

```apex theme={null}
try {
    paymentGateway.charge(amount);
} catch (Exception e) {
    ErrorLogger.log(e, 'PaymentService', 'processPayment', 'CRITICAL');
}
```

**With record context:**

```apex theme={null}
try {
    processOrder(orderId);
} catch (Exception e) {
    ErrorLogger.log(e, 'OrderService', 'processOrder', 'ERROR', orderId);
}
```

## Important notes

* `ErrorLogger` is designed to **never throw**. If publishing the Platform Event fails for any reason, the error is silently swallowed — your calling code is never affected.
* All logging is done asynchronously via Platform Events. There is no performance impact on the transaction that calls it.
* If you catch an exception and also re-throw it, call `ErrorLogger.log()` before re-throwing.
