# X402AvmError

> Typed errors thrown by x402-avm-js.

```ts
import { X402AvmError } from 'x402-avm-js';
```

```ts
export class X402AvmError extends Error {
  /** Stable machine-readable identifier of the error kind. */
  readonly code: string;

  constructor(message: string, code = 'x402_avm_error', options?: { cause?: unknown }) {
    super(message, options);
    this.name = new.target.name;
    this.code = code;
  }
}
```

Typed errors thrown by x402-avm-js. Every error extends {@link X402AvmError}, carries a stable
string `code`, and sets `name` to the class name, so callers can use `instanceof` or `error.code`.

Source: [src/errors.ts](https://github.com/x402-avm/x402-avm-js/blob/main/src/errors.ts#L6)

Source: https://x402-avm.github.io/reference/js/x402-avm-error
