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

# TypeScript Errors

> Handle HTTP, WebSocket, reconnect, overflow, and orderbook-integrity failures in TypeScript.

```typescript theme={null}
import {
  ApiError,
  OrderbookIntegrityError,
  PolyNodeError,
  WsError,
} from 'polynode-sdk';

try {
  await pn.v3.stats();
} catch (error) {
  if (error instanceof ApiError) {
    console.error({
      status: error.status,
      code: error.code,
      hint: error.hint,
      requestId: error.requestId,
      retryAfter: error.retryAfter,
      rateLimit: error.rateLimit,
      method: error.safeMethod,
      url: error.safeUrl,
    });
  } else if (error instanceof WsError) {
    console.error(error.code, error.message);
  } else if (error instanceof OrderbookIntegrityError) {
    console.error(error.code, error.token, error.message);
  } else if (error instanceof PolyNodeError) {
    console.error(error.code, error.message);
  }
  throw error;
}
```

Safe V3 reads retry transient transport failures and retryable statuses. State-changing V3 calls are never retried automatically. After a mutation timeout, check whether the resource changed before submitting it again.

WebSocket reconnect and data-quality signals are separate from thrown errors:

* `pn.ws.onReplay(...)` reports best-effort settlement replay;
* `sub.onOverflow(...)` reports local event loss;
* `perps.onReconnect(...)` reports a possible perps gap;
* `perps.onOverflow(...)` reports local perps loss;
* `integrity_error` moves an affected PN1 book away from `ready` until a fresh anchor succeeds.

Log request IDs and redacted safe URLs, but never log API keys, private keys, builder credentials, CLOB secrets, or signed payloads.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.