Athos Developer Docs
Frontend SDK

Error codes

The SDK error taxonomy and how to handle each failure.

Errors surface two ways, and you should handle both:

  • as an error eventsession.on('error', ({ code, message }) => …);
  • as a rejected promise from connect()await session.connect().catch(…).

Always branch on code. message is human-readable and may change — never parse it. The full runtime list is exported as ATHOS_ERROR_CODES.

import { AthosRoleplayError } from '@useathos/sdk';

session.on('error', ({ code, message }) => {
  switch (code) {
    case 'MIC_PERMISSION_DENIED': return promptForMicAccess();
    case 'AUDIO_PLAYBACK_BLOCKED': return showResumeButton();
    case 'NETWORK_LOST': return offerRestart();
    default: console.error(code, message);
  }
});

Codes the SDK emits

These originate in the browser at runtime:

CodeMeaning
MIC_PERMISSION_DENIEDThe user denied microphone permission.
MIC_DEVICE_DISCONNECTEDThe active microphone was unplugged mid-call.
NO_MIC_AVAILABLENo microphone is available on this device.
NETWORK_LOSTThe connection dropped and could not recover within 30s. The session ended.
AUDIO_PLAYBACK_BLOCKEDThe browser blocked audio autoplay; call resumeAudio() from a user gesture.
BROWSER_NOT_SUPPORTEDSafari / mobile / unsupported browser (thrown synchronously from create()).
SESSION_ALREADY_CONNECTEDconnect() was called twice on the same session.

Codes from the session redemption

When connect() redeems the token, the server may reject it. These surface through the same error channel:

CodeMeaningWhat to do
INVALID_TOKENThe token was malformed or rejected.Mint a fresh token.
TOKEN_EXPIREDThe token's ~5-minute lifetime elapsed before connecting.Mint at "start" click, not page load.
TOKEN_ALREADY_USEDThe single-use token was already redeemed.Mint a new token per call.
DRILL_NOT_FOUNDThe drillKey doesn't match a known drill.Check the Drills reference.
INVALID_REQUESTThe request was invalid (e.g. blank drillKey).Fix the create() options.
TENANT_INACTIVEYour Athos tenant is inactive.Contact Athos.
TENANT_QUOTA_EXCEEDEDYour tenant exceeded its usage quota.Contact Athos.
SERVICE_UNAVAILABLEAthos is temporarily unavailable.Retry shortly.
INTERNAL_ERRORAn unexpected error.Retry; if it persists, contact Athos with the message.

The token-lifecycle codes (INVALID_TOKEN, TOKEN_EXPIRED, TOKEN_ALREADY_USED) almost always trace back to when you mint the token. Mint it the instant the rep clicks "start practice", use it once, and let it expire — see Authentication.

On this page