The single error type returned by every public LiveKit SDK function.
LiveKit.Error is both an exception (so bang functions can raise it) and a
plain struct that is returned inside {:error, error} tuples by the
non-bang API.
iex> {:error, error} = LiveKit.Config.new(url: "https://example.livekit.cloud")
iex> error.type
:configurationRedaction
Errors are frequently logged or inspected by callers, so this module goes out of its way to never carry credentials:
metavalues are sanitized withsanitize/1, which drops well-known credential keys and replaces JWT-shaped strings with"[REDACTED]".- The derived
Inspectimplementation is the default struct one, but since no field ever holds a secret, inspecting an error is safe.
Anything placed into meta by the SDK passes through sanitize/1 first.
Summary
Functions
Builds an :authentication error.
Builds a :configuration error.
Builds a :decoding error.
Builds an :encoding error.
Builds an :http error for a non-success response without a Twirp payload.
Builds an error.
Removes credentials from an arbitrary metadata map.
Builds a :timeout error. Timeouts are retryable by default.
Builds a :transport error. Transport failures are retryable by default.
Builds a :twirp error from a decoded Twirp JSON error body.
Builds a :validation error.
Types
@type error_type() ::
:configuration
| :validation
| :authentication
| :transport
| :timeout
| :http
| :twirp
| :encoding
| :decoding
| :protobuf
| :unknown
Classification of a failure.
:configuration- invalid client/config construction options:validation- invalid arguments to an otherwise well-formed call:authentication- the service token could not be built or was rejected:transport- the request never produced an HTTP response:timeout- connect or receive timeout:http- non-success HTTP response that is not a Twirp error:twirp- structured Twirp JSON error payload:encoding- request could not be encoded:decoding- response body could not be decoded:protobuf- protobuf specific encode/decode failure:unknown- anything that could not be classified
@type t() :: %LiveKit.Error{ __exception__: true, code: String.t() | nil, message: String.t(), meta: map(), retryable: boolean(), status: pos_integer() | nil, type: error_type() }
Functions
Builds an :authentication error.
Examples
iex> LiveKit.Error.authentication("no grant requested").type
:authentication
Builds a :configuration error.
Examples
iex> LiveKit.Error.configuration("url is required").type
:configuration
Builds a :decoding error.
Examples
iex> LiveKit.Error.decoding("malformed protobuf response").type
:decoding
Builds an :encoding error.
Examples
iex> LiveKit.Error.encoding("request is not a protobuf struct").type
:encoding
Builds an :http error for a non-success response without a Twirp payload.
Server-side statuses (5xx) plus 408 and 429 are marked retryable.
Examples
iex> LiveKit.Error.http("bad gateway", status: 502).retryable
true
Builds an error.
:type and :message are required; everything else is optional. :meta is
always passed through sanitize/1.
Examples
iex> error = LiveKit.Error.new(type: :validation, message: "ttl must be positive")
iex> {error.type, error.retryable}
{:validation, false}
Removes credentials from an arbitrary metadata map.
Keys matching well-known credential names are dropped entirely, and values
that look like a JWT (three base64url segments separated by .) are replaced
with "[REDACTED]". Nested maps and lists are sanitized recursively.
Examples
iex> LiveKit.Error.sanitize(%{"api_secret" => "s3cret", "room" => "lobby"})
%{"room" => "lobby"}
iex> LiveKit.Error.sanitize(%{"detail" => "Bearer eyJhbGciOiJIUzI1NiJ9.eyJhIjoxfQ.sig"})
%{"detail" => "[REDACTED]"}
Builds a :timeout error. Timeouts are retryable by default.
Examples
iex> LiveKit.Error.timeout("receive timeout").retryable
true
Builds a :transport error. Transport failures are retryable by default.
Examples
iex> LiveKit.Error.transport("connection refused").retryable
true
Builds a :twirp error from a decoded Twirp JSON error body.
Examples
iex> error = LiveKit.Error.twirp("room not found", code: "not_found", status: 404)
iex> {error.code, error.retryable}
{"not_found", false}
Builds a :validation error.
Examples
iex> LiveKit.Error.validation("ttl must be positive").type
:validation