***

title: RelayError
slug: /reference/typescript/relay/relay-error
description: Error thrown when the RELAY server returns an error.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

Custom error class for RELAY protocol errors. Extends JavaScript's built-in `Error`
class. The `name` property is always `"RelayError"`.

```typescript {1}
import { RelayError } from '@signalwire/sdk';
```

## **Properties**

<ParamField path="code" type="number" default="0" toc={true}>
  Numeric error code returned by the RELAY server.
</ParamField>

<ParamField path="message" type="string" toc={true}>
  Human-readable error description returned by the RELAY server.
</ParamField>

<ParamField path="name" type="string" toc={true}>
  Always `"RelayError"`.
</ParamField>

## **Examples**

### Catch a RELAY error

```typescript {9}
import { RelayClient, RelayError } from '@signalwire/sdk';

const client = new RelayClient({
  project: process.env.SIGNALWIRE_PROJECT_ID!,
  token: process.env.SIGNALWIRE_TOKEN!,
  contexts: ['default'],
});

client.onCall(async (call) => {
  try {
    await call.connect(
      [[{ type: 'phone', params: { to_number: '+15559876543' } }]],
    );
  } catch (e) {
    if (e instanceof RelayError) {
      console.log(`Error ${e.code}: ${e.message}`);
    }
    await call.hangup();
  }
});

await client.run();
```