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
codeTwirp.ErrorCodeThe Twirp error code.
messagestringThe error message.
statusintThe HTTP status of the response, 0 when unknown.
metaIReadOnlyDictionary<string, string>The
metamap 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
Status
HTTP status of the response, 0 when unknown.
public int Status { get; }
Property Value
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
Returns
- TwirpException
The exception describing the error.