Skip to main content

Errors

The SDK throws typed errors that you can match with instanceof. All errors live on the package root export.

import {
CapabilityNotSupportedError,
ReadAloudCapabilityNotFoundError,
SessionOpenError,
SessionClosedError,
ChannelTransportError,
} from '@ki-kombinat/delphi-client-js-sdk';

Typed errors

ErrorWhenKey fields
CapabilityNotSupportedErrorassertCapability / assertEndpointCapability and the endpoint doesn't expose the capability.capability, endpointId
ReadAloudCapabilityNotFoundErrorreadAloud cannot resolve a read-aloud BOA on the endpoint (none registered, or capabilityId / identifier doesn't match).endpointId, capabilityId?
SessionOpenErrorThe session-token request, the gateway handshake, or the SIP plugin attach failed.cause, mode, endpointId
SessionClosedErrorMethod invoked on a session that has already closed (idle timeout, explicit close, or transport failure past the reconnect window).mode, endpointId
ChannelTransportErrorThe channel WebSocket failed and the reconnect window expired.code, reason

Pattern

import {
CapabilityNotSupportedError,
ReadAloudCapabilityNotFoundError,
} from '@ki-kombinat/delphi-client-js-sdk';

try {
await delphi.readAloud(text, {endpointId});
} catch (err) {
if (err instanceof CapabilityNotSupportedError) {
console.warn(`Endpoint ${err.endpointId} does not support ${err.capability}.`);
return;
}
if (err instanceof ReadAloudCapabilityNotFoundError) {
console.warn('Endpoint has no read-aloud BOA registered.');
return;
}
throw err;
}

Server-side errors

Errors originating on the server arrive as ChannelMessage with type: 'error' and error: ErrorPayload. The SDK maps recognised codes onto the typed-error classes above; unknown codes surface as the raw payload via the session's lastError. See Channel protocol.