Exception: Jortt::Client::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Jortt::Client::Error
- Defined in:
- lib/jortt/client/error.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(code, key, message, details) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(code, key, message, details) ⇒ Error
Returns a new instance of Error.
15 16 17 18 19 20 21 22 |
# File 'lib/jortt/client/error.rb', line 15 def initialize(code, key, , details) @code = code @key = key = @details = details super() end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/jortt/client/error.rb', line 4 def code @code end |
#details ⇒ Object (readonly)
Returns the value of attribute details.
4 5 6 |
# File 'lib/jortt/client/error.rb', line 4 def details @details end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/jortt/client/error.rb', line 4 def key @key end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
4 5 6 |
# File 'lib/jortt/client/error.rb', line 4 def end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/jortt/client/error.rb', line 4 def response @response end |
Class Method Details
.from_response(response) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/jortt/client/error.rb', line 6 def self.from_response(response) Error.new( response.parsed.dig('error', 'code'), response.parsed.dig('error', 'key'), response.parsed.dig('error', 'message'), response.parsed.dig('error', 'details') ) end |
Instance Method Details
#error_message ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/jortt/client/error.rb', line 24 def [].tap do |m| details.each do |detail| m << "#{detail['param']} #{detail['message']}" end end.join("\n") end |