Exception: LiveKit::ServerError
- Inherits:
-
StandardError
- Object
- StandardError
- LiveKit::ServerError
- Defined in:
- lib/livekit/errors.rb
Overview
Raised when a LiveKit server API call fails. Exposes the error code, message, and any metadata the server attached.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#code ⇒ String
readonly
The error code, e.g.
-
#metadata ⇒ Hash{String=>String}
readonly
Error metadata returned by the server.
Class Method Summary collapse
-
.from(err) ⇒ LiveKit::ServerError?
Builds a ServerError (or SipCallError) from the underlying error.
Instance Method Summary collapse
-
#initialize(code, message, metadata: {}) ⇒ ServerError
constructor
A new instance of ServerError.
Constructor Details
#initialize(code, message, metadata: {}) ⇒ ServerError
Returns a new instance of ServerError.
12 13 14 15 16 |
# File 'lib/livekit/errors.rb', line 12 def initialize(code, , metadata: {}) @code = code @metadata = || {} super() end |
Instance Attribute Details
#code ⇒ String (readonly)
Returns the error code, e.g. "not_found" or "permission_denied".
8 9 10 |
# File 'lib/livekit/errors.rb', line 8 def code @code end |
#metadata ⇒ Hash{String=>String} (readonly)
Returns error metadata returned by the server.
10 11 12 |
# File 'lib/livekit/errors.rb', line 10 def @metadata end |
Class Method Details
.from(err) ⇒ LiveKit::ServerError?
Builds a ServerError (or SipCallError) from the underlying error. Returns nil
when err is nil, so it can be called directly on a response's error.
21 22 23 24 25 26 27 |
# File 'lib/livekit/errors.rb', line 21 def self.from(err) return nil if err.nil? = err. || {} klass = .key?("sip_status_code") ? SipCallError : self klass.new(err.code.to_s, err.msg, metadata: ) end |