Creates an SDK error. The SDK builds these itself; applications normally only catch them.
Human-readable description of the failure, used as the Error message.
Stable machine-readable code for the failure.
OptionaloriginalError: unknown
The underlying error or value this one wraps, when there is one.
ReadonlykindStable machine-readable code for this failure, and the value to branch on.
Every subclass redeclares it as the literal it always carries, so a switch on kind
narrows a value isDIDError has recognized to that class: 'HttpError' on
HttpError, 'NetworkError' on NetworkError, 'WSError' on
WsError, 'StreamError' on StreamError, 'ValidationError' on
ValidationError, 'ChatCreationFailed' on ChatCreationFailed and
'ChatModeDowngraded' on ChatModeDowngraded. It stays a plain string here on
the base class: on a BaseError built directly it is whatever the caller passed, and
'Error' when nothing was. The Agents API's own classification of a failed request is
HttpError.code, not this.
Optional ReadonlyoriginalThe error or value that caused this one, when the SDK was wrapping something else.
For a NetworkError this is the browser's own fetch rejection. It is not
serialized as-is: toJson() takes only an Error cause's
message.
Serializes the error into the JSON-safe ErrorJson payload for logging or reporting.
The payload always carries kind and the message. The cause's message
is added only when originalError is an Error and says
something the message does not, truncated to 256 characters; any other cause is dropped.
Subclasses extend the payload with the fields listed on their own pages.
The error as plain, JSON-serializable data.
Base class of every error the SDK itself raises.
Catching
BaseErrorcatches everything the SDK classified; branch on kind, which is stable, rather than on the message, which is not. Errors reach the application two ways, and each subclass says which applies: some are thrown to the caller of the method, so they reject the promise it returned; others are handed to onError because no call of yours was in flight when they happened. HttpError and NetworkError do both — the request that failed rejects, and the callback is notified as well.Not everything that reaches the application is one of these. The streaming transport is the main exception: a failure LiveKit raises inside a media call on an Expressive (V4) agent — no microphone publication to replace, a room that is not connected — rejects with a plain
Error, and so do a few low-level guards inside connect(), such as alivekit-clientpackage that is not installed, a transport the SDK does not recognize, or a stream the server created without a session id. An unknown auth type is a plainErrortoo. So keep theelse throw errorbranch in a handler built on isDIDError.Subclasses: HttpError, NetworkError, WsError, StreamError, ValidationError, ChatCreationFailed and ChatModeDowngraded. When the caught value is typed
unknown, isDIDError narrows it to DIDError, the union of those seven, so aswitchon kind then narrows it to one class.