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

# EndstateWalletError

> A wallet request failed. Carries a code you branch on, plus docUrl, requestId, and details. Thrown by ready(), refreshSession(), and other wallet calls.

```ts theme={null}
class EndstateWalletError extends Error {
  readonly name: "EndstateWalletError";
  readonly code: string;
  readonly docUrl?: string;
  readonly requestId?: string;
  readonly details?: Record<string, unknown>;
}
```

Branch on `code`, never on `message`. A `code` is a `wallet.*` code from the frame, an API error code forwarded verbatim, or a code this package produced locally.

## Example

```ts theme={null}
import { EndstateWalletError } from "@endstate-sdk/web";

try {
  await wallet.ready();
} catch (error) {
  if (error instanceof EndstateWalletError) {
    if (error.code === "wallet.session_expired") {
      await wallet.refreshSession();
    } else {
      log(error.code, error.requestId);
    }
  }
}
```

## Properties

<ResponseField name="code" type="string" required>
  The stable failure code to branch on. See [Codes](#codes) below.
</ResponseField>

<ResponseField name="docUrl" type="string">
  Documentation for this code, when the failure carried one.
</ResponseField>

<ResponseField name="requestId" type="string">
  Present when the failure originated at the Endstate API. Quote it in support
  requests.
</ResponseField>

<ResponseField name="details" type="Record<string, unknown>">
  Structured context attached to the failure, when the wallet or API supplied
  it.
</ResponseField>

## Codes

`code` comes from three places. Frame `wallet.*` codes and Endstate API codes pass through verbatim; the package also produces a handful of codes locally:

<ResponseField name="wallet.session_expired" type="frame">
  The session lapsed. Call
  [`refreshSession()`](/sdks/web/reference/wallet/EndstateWallet) to establish a
  fresh one.
</ResponseField>

<ResponseField name="wallet.timeout" type="local">
  No response within the wait budget. The frame handshake, identity issuance,
  session establishment, or wallet setup exceeded its `timeouts` budget.
</ResponseField>

<ResponseField name="wallet.destroyed" type="local">
  `destroy()` settled this call. The wallet was torn down while the request was
  pending.
</ResponseField>

<ResponseField name="wallet.unsupported_protocol_version" type="local">
  The wallet frame does not speak the bridge protocol version this package
  sends. Upgrade `@endstate-sdk/web`. `details.supported` lists the versions the
  frame offered.
</ResponseField>

<ResponseField name="wallet.internal_error" type="local">
  The wallet's reply could not be used - for example, a session reported without
  an account address, or a failure that carried no usable `code`.
</ResponseField>

Other `wallet.*` codes and API error codes (for example a rejected credential) pass through unchanged. Always match on the exact string, and treat an unrecognized `code` as a generic failure rather than assuming a fixed set.
