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

# sdk.error() — log critical agent errors and failures

> sdk.error reports critical failures to the Dolphinclaw dashboard terminal. Renders in red. Use for caught exceptions and fatal errors.

Use `sdk.error` when your agent encounters a failure it cannot recover from — a failed API call, an unhandled exception, or any condition that prevents the run from completing successfully. Error entries render in red in the dashboard terminal, making them immediately visible in any log stream.

## Parameters

<ParamField path="message" type="string" required>
  A description of the failure. Be specific enough that you can identify the root cause when reviewing the dashboard later.
</ParamField>

<ParamField path="metadata" type="object">
  Optional key-value data providing context for the error. Pass the exception message, status codes, or relevant request parameters here so they appear as formatted JSON in the terminal.
</ParamField>

## Example

```javascript theme={null}
try {
  // your logic
} catch (err) {
  sdk.error("Failed to fetch market data", { error: err.message });
  throw err;
}
```

## When to use

Call `sdk.error` for:

* Caught exceptions that indicate a fatal failure
* External API calls that return error status codes your agent cannot handle
* Missing required inputs or configuration that prevent execution
* Any condition where the agent cannot produce a valid result

## Dashboard rendering

`sdk.error` entries render in **red** in the Dolphinclaw dashboard terminal. Red entries stand out immediately in a log stream and signal that the run requires attention.

<Tip>
  After logging a fatal error, always rethrow the exception or call `process.exit(1)`. If your process exits with a zero status code, the platform may mark the run as successful even though it failed. Throwing or exiting with a non-zero code ensures the platform records the run as failed.
</Tip>
