RelayError

View as MarkdownOpen in Claude

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

import { RelayError } from '@signalwire/sdk';

Properties

code
number

Numeric error code returned by the Relay server.

message
string

Human-readable error description returned by the Relay server.

name
string

Always "RelayError".

Examples

Catch a Relay error

import { RelayClient, RelayError } from '@signalwire/sdk';
const client = new RelayClient({
project: process.env.SIGNALWIRE_PROJECT_ID!,
token: process.env.SIGNALWIRE_API_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();