Exception: Twirbet::BaseError
- Inherits:
-
StandardError
- Object
- StandardError
- Twirbet::BaseError
show all
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/twirbet/errors.rb
Direct Known Subclasses
AbortedError, AlreadyExistsError, BadRouteError, CanceledError, DataLossError, DeadlineExceededError, FailedPreconditionError, InternalError, InvalidArgumentError, MalformedError, NotFoundError, OutOfRangeError, PermissionDeniedError, ResourceExhaustedError, UnauthenticatedError, UnavailableError, UnimplementedError, UnknownError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(message, metadata = {}) ⇒ BaseError
Returns a new instance of BaseError.
19
20
21
22
|
# File 'lib/twirbet/errors.rb', line 19
def initialize(message, metadata = {})
super(message)
@metadata = metadata
end
|
Instance Attribute Details
Returns the value of attribute metadata.
16
17
18
|
# File 'lib/twirbet/errors.rb', line 16
def metadata
@metadata
end
|
Instance Method Details
#code ⇒ Object
25
26
|
# File 'lib/twirbet/errors.rb', line 25
def code
end
|
#status ⇒ Object
29
30
|
# File 'lib/twirbet/errors.rb', line 29
def status
end
|
#to_hash ⇒ Object
43
44
45
|
# File 'lib/twirbet/errors.rb', line 43
def to_hash
{ "code" => code, "msg" => message, "meta" => metadata }
end
|
#to_json ⇒ Object
38
39
40
|
# File 'lib/twirbet/errors.rb', line 38
def to_json
T.unsafe(to_hash).to_json
end
|
#to_rack_response ⇒ Object
33
34
35
|
# File 'lib/twirbet/errors.rb', line 33
def to_rack_response
Rack::Response.new(to_json, status, "Content-Type" => "application/json")
end
|