Exception: Mistral::APIError
- Defined in:
- lib/mistral/exceptions.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message: nil, http_status: nil, headers: nil) ⇒ APIError
constructor
A new instance of APIError.
- #to_s ⇒ Object
Constructor Details
#initialize(message: nil, http_status: nil, headers: nil) ⇒ APIError
Returns a new instance of APIError.
11 12 13 14 15 16 |
# File 'lib/mistral/exceptions.rb', line 11 def initialize(message: nil, http_status: nil, headers: nil) super(message: ) @http_status = http_status @headers = headers end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
9 10 11 |
# File 'lib/mistral/exceptions.rb', line 9 def headers @headers end |
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
9 10 11 |
# File 'lib/mistral/exceptions.rb', line 9 def http_status @http_status end |
Class Method Details
.from_response(response, message: nil) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/mistral/exceptions.rb', line 18 def self.from_response(response, message: nil) new( message: || response.to_s, http_status: response.code, headers: response.headers.to_h ) end |
Instance Method Details
#to_s ⇒ Object
26 27 28 |
# File 'lib/mistral/exceptions.rb', line 26 def to_s "#{self.class.name}(message=#{super}, http_status=#{http_status})" end |