Table of Contents

Class TwirpException

Namespace
Livekit.Server.Sdk.Dotnet
Assembly
LivekitApi.dll

Error returned by the LiveKit server for a service call. It derives from the generated Twirp.Exception, so existing catch blocks keep working, and adds the HTTP status and the meta map of the Twirp error (for example sip_status_code for SIP calls). The Twirp error code is in the inherited Type property.

public class TwirpException : Twirp.Exception, ISerializable
Inheritance
TwirpException
Implements
Inherited Members

Constructors

TwirpException(ErrorCode, string, int, IReadOnlyDictionary<string, string>)

Creates a new error.

public TwirpException(Twirp.ErrorCode code, string message, int status = 0, IReadOnlyDictionary<string, string> meta = null)

Parameters

code Twirp.ErrorCode

The Twirp error code.

message string

The error message.

status int

The HTTP status of the response, 0 when unknown.

meta IReadOnlyDictionary<string, string>

The meta map of the Twirp error.

Properties

Meta

The meta map of the Twirp error, empty when the server sent none.

public IReadOnlyDictionary<string, string> Meta { get; }

Property Value

IReadOnlyDictionary<string, string>

Status

HTTP status of the response, 0 when unknown.

public int Status { get; }

Property Value

int

Methods

FromResponse(string, int)

Builds the error from a non-2xx response body, which is a Twirp JSON error ({"code":"...","msg":"...","meta":{...}}) or, from proxies, anything else. The service clients call it for every failed request; it is public for code that sends Twirp requests itself.

public static TwirpException FromResponse(string body, int status)

Parameters

body string

The response body.

status int

The HTTP status of the response.

Returns

TwirpException

The exception describing the error.