Exception: Octoparts::ResponseError
- Defined in:
- lib/octoparts/error.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(response) ⇒ ResponseError
constructor
A new instance of ResponseError.
Constructor Details
#initialize(response) ⇒ ResponseError
Returns a new instance of ResponseError.
17 18 19 20 |
# File 'lib/octoparts/error.rb', line 17 def initialize(response) @response = response super() end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/octoparts/error.rb', line 5 def response @response end |
Class Method Details
.from_response(response) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/octoparts/error.rb', line 7 def self.from_response(response) status = response.status.to_i klass = case status when 400..499 then Octoparts::ClientError when 500..599 then Octoparts::ServerError end klass.new(response) unless klass.nil? end |
Instance Method Details
#error_message ⇒ Object
22 23 24 |
# File 'lib/octoparts/error.rb', line 22 def "status: #{@response.status}, body: #{@response.body}" end |