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

# record_exception()

> Record an exception on the current span and set error status

## Overview

```python theme={"system"}
record_exception(exception: Exception, attributes: Dict = None, timestamp: int = None, escaped: bool = False) -> bool
```

## Example

```python theme={"system"}
from keywordsai_tracing import task, get_client

@task(name="fail_demo")
def fail_demo():
    client = get_client()
    try:
        raise ValueError("bad input")
    except Exception as e:
        client.record_exception(e, {"phase": "validation"})
        return "handled"

print(fail_demo())
```
