Exception: Candid::Errors::ResponseError
- Defined in:
- lib/candid/errors/response_error.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Class Method Summary collapse
-
.subclass_for_code(code) ⇒ Class
Returns the most appropriate error class for the given code.
Instance Method Summary collapse
-
#initialize(msg, code:) ⇒ ResponseError
constructor
A new instance of ResponseError.
- #inspect ⇒ Object
Constructor Details
#initialize(msg, code:) ⇒ ResponseError
Returns a new instance of ResponseError.
8 9 10 11 |
# File 'lib/candid/errors/response_error.rb', line 8 def initialize(msg, code:) @code = code super(msg) end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/candid/errors/response_error.rb', line 6 def code @code end |
Class Method Details
.subclass_for_code(code) ⇒ Class
Returns the most appropriate error class for the given code.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/candid/errors/response_error.rb', line 20 def self.subclass_for_code(code) case code when 300..399 RedirectError when 401 when 403 ForbiddenError when 404 NotFoundError when 400..499 ClientError when 503 ServiceUnavailableError when 500..599 ServerError else ResponseError end end |
Instance Method Details
#inspect ⇒ Object
13 14 15 |
# File 'lib/candid/errors/response_error.rb', line 13 def inspect "#<#{self.class.name} @code=#{code} @body=#{message}>" end |