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

# From Exception • AI Agent SDK

> from_exception: Normalise a raised exception into a canonical terminal outcome.

# from\_exception

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**RunOutcome**](../classes/RunOutcome) class in the [**run\_outcome**](../modules/run_outcome) module.

Normalise a raised exception into a canonical terminal outcome.

Maps well-known exception types to their terminal reason. Anything
unrecognised is treated as `failed` with a redacted message.

Note on `hard_timeout`: the run-level budget is the authoritative
source of `hard_timeout` and is applied explicitly by the caller
(see `_astart_with_outcome`). A bare `asyncio.TimeoutError` reaching
this normaliser is a *nested* operation timeout (e.g. a handoff/tool that
exhausted its own budget while the run budget remained) and is therefore
classified as `failed` — not silently promoted to a run-budget
`hard_timeout`, which would drive the wrong host retry/DLQ decision.
Real cooperative cancellation is intercepted and re-raised by the run
wrapper (see `_astart_with_outcome`) *before* it reaches this
normaliser, so host shutdown is honoured. A supersede/interrupt named
error that does surface here is a domain "cancelled" outcome.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def from_exception(exc: BaseException, output: Optional[str]) -> 'RunOutcome'
```

## Parameters

<ParamField query="exc" type="BaseException" required={true}>
  No description available.
</ParamField>

<ParamField query="output" type="Optional[str]" required={false}>
  No description available.
</ParamField>

### Returns

<ResponseField name="Returns" type="'RunOutcome'">
  The result of the operation.
</ResponseField>

## Uses

* `cls`

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/run_outcome.py#L60">
  `praisonaiagents/agent/run_outcome.py` at line 60
</Card>
