Exception: ApiaClient::RequestError
- Inherits:
-
StandardError
- Object
- StandardError
- ApiaClient::RequestError
- Defined in:
- lib/apia_client/errors/request_error.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #code ⇒ Object
- #description ⇒ Object
- #detail ⇒ Object
-
#initialize(client, status, body) ⇒ RequestError
constructor
rubocop:disable Lint/MissingSuper.
-
#to_s ⇒ Object
rubocop:enable Lint/MissingSuper.
Constructor Details
#initialize(client, status, body) ⇒ RequestError
rubocop:disable Lint/MissingSuper
10 11 12 13 14 15 16 |
# File 'lib/apia_client/errors/request_error.rb', line 10 def initialize(client, status, body) @client = client @status = status @body = body @error = @body['error'] end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/apia_client/errors/request_error.rb', line 7 def body @body end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/apia_client/errors/request_error.rb', line 6 def status @status end |
Instance Method Details
#code ⇒ Object
31 32 33 34 35 |
# File 'lib/apia_client/errors/request_error.rb', line 31 def code return if @error.nil? @error['code'] end |
#description ⇒ Object
37 38 39 40 41 |
# File 'lib/apia_client/errors/request_error.rb', line 37 def description return if @error.nil? @error['description'] end |
#detail ⇒ Object
43 44 45 46 47 |
# File 'lib/apia_client/errors/request_error.rb', line 43 def detail return if @error.nil? @error['detail'] || {} end |
#to_s ⇒ Object
rubocop:enable Lint/MissingSuper
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/apia_client/errors/request_error.rb', line 19 def to_s string = ["[#{@status}]"] if code && description string << "#{code}: #{description}" elsif code string << code else string << @body end string.join(' ') end |