Skip to navigation

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

"RELAY error {code}: {serverMessage}". The standard Error message, prefixed with the code.

serverMessage
string

The server’s own error text, without the RELAY error prefix. Read this to match on or display the server’s wording.

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();