Exception: Bright::ResponseError
- Defined in:
- lib/bright/errors.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(response, uri = nil) ⇒ ResponseError
constructor
A new instance of ResponseError.
- #server_error? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(response, uri = nil) ⇒ ResponseError
Returns a new instance of ResponseError.
6 7 8 9 |
# File 'lib/bright/errors.rb', line 6 def initialize(response, uri = nil) @response = response @uri = uri end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/bright/errors.rb', line 3 def response @response end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
4 5 6 |
# File 'lib/bright/errors.rb', line 4 def uri @uri end |
Instance Method Details
#body ⇒ Object
15 16 17 |
# File 'lib/bright/errors.rb', line 15 def body response.body end |
#server_error? ⇒ Boolean
19 20 21 |
# File 'lib/bright/errors.rb', line 19 def server_error? (500..599).include?(response&.code.to_i) end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/bright/errors.rb', line 11 def to_s "Failed with #{response.code} #{response. if response.respond_to?(:message)}".strip end |