Exception: Twirbet::BaseError

Inherits:
StandardError
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/twirbet/errors.rb

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,  = {})
  super(message)
  @metadata = 
end

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata.



16
17
18
# File 'lib/twirbet/errors.rb', line 16

def 
  @metadata
end

Instance Method Details

#codeObject



25
26
# File 'lib/twirbet/errors.rb', line 25

def code
end

#statusObject



29
30
# File 'lib/twirbet/errors.rb', line 29

def status
end

#to_hashObject



43
44
45
# File 'lib/twirbet/errors.rb', line 43

def to_hash
  { "code" => code, "msg" => message, "meta" =>  }
end

#to_jsonObject



38
39
40
# File 'lib/twirbet/errors.rb', line 38

def to_json
  T.unsafe(to_hash).to_json
end

#to_rack_responseObject



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