Skip to main content

Error Codes

The widget emits structured errors through the error event and surfaces them in logs. Each error carries a stable code (e.g. AUTH_001), a category, a human-readable message, and optionally a details payload with additional context.

TraiseWidget.on('error', (err) => {
if (err.category === 'auth') {
// handle auth failure (bad API key, account disabled, etc.)
}
console.error(err.code, err.message, err.details);
});

Codes are grouped by category. Use the category to branch on broad failure classes; use the code when you need precise behaviour for a specific case.

Authentication

CodeMeaning
AUTH_001Invalid API key
AUTH_002API key expired or revoked
AUTH_003Account not found

Voice

CodeMeaning
VOICE_001Microphone permission denied
VOICE_002Call failed to connect
VOICE_003Voice token refresh failed
VOICE_004No voice device available

SMS

CodeMeaning
SMS_001Message send failed
SMS_002Invalid phone number
SMS_003SMS room creation failed

WebSocket / Network

CodeMeaning
WS_001WebSocket connection failed
WS_002Max reconnection attempts reached
WS_003Connection rejected by server

API

CodeMeaning
API_001Request timeout
API_002Server error
API_003Rate limited

Handling Errors

Ignore vs. surface

Not every error needs user-facing handling. Network blips that auto-recover (WS_001 when reconnection succeeds on the next attempt) can be logged and ignored. Auth failures (AUTH_001, AUTH_002) usually warrant surfacing — the widget can't recover on its own and the integrator needs to refresh or rotate the API key.

Unknown codes

If the widget emits a code not listed above, it will still carry a category of api and a descriptive message. Catch-all branches on err.category are safe; switches on err.code should include a default.