06 Line
Browser SDK

Errors

PhoneError and its codes.

Every rejected promise and every error event carries a PhoneError; match it with instanceof:

class PhoneError extends Error {
  code: string;        // match on this
  requestId?: string;  // give it to support
  param?: string;      // offending field, for API errors
}

code is one of the API error codes, or one of these, specific to the browser:

CodeCauseWhat to do
microphone_deniedThe user or the browser refused microphone accessExplain how to allow it in the browser settings
microphone_not_foundNo microphone, or the chosen one was unplugged (mid-call too: then sent as an error event and the call is muted)Ask the user to plug one in or pick another
speaker_not_foundThe chosen speaker is unplugged, or the browser did not allow itPick another one, or leave the default
audio_unavailableThe page cannot run Web Audio or reach media devices (old browser, insecure origin)Serve the page over HTTPS, update the browser
user_gesture_requiredcall(), answer() or testMicrophone() ran outside a user action, or the browser blocked the soundCall them from a click handler
not_supportedAn output was set in a browser that cannot choose the speakerHide the speaker picker when phone.canChooseOutput is false
ephemeral_key_failedgetEphemeralKey threw or did not return the JSON of POST /v1/ephemeral-keysCheck your server route
connection_lostThe WebRTC session could not be restored for 2 minutes (network down, UDP and TURN blocked)Show it, offer to retry with phone.connect()

Two API codes also come from the SDK itself: line_offline when you call while the phone is not connected, and invalid_request with param: 'lineId' when call() cannot pick a line. Anything unexpected is internal.