Exception: Consulkit::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Consulkit::Error
- Defined in:
- lib/consulkit/error.rb
Overview
An error returned from the Consul API.
Defined Under Namespace
Classes: ACLNotFound, BadRequest, Client, Forbidden, NotFound, Server
Class Method Summary collapse
-
.from_response(response) ⇒ Object
Returns the appropriate Consulkit::Error subclass based on the status and response message, or nil if the response is not an error.
Instance Method Summary collapse
-
#initialize(response) ⇒ Error
constructor
A new instance of Error.
- #response_body ⇒ Object
- #response_headers ⇒ Object
- #response_status ⇒ Object
Constructor Details
#initialize(response) ⇒ Error
Returns a new instance of Error.
7 8 9 10 11 |
# File 'lib/consulkit/error.rb', line 7 def initialize(response) @response = response super() end |
Class Method Details
.from_response(response) ⇒ Object
Returns the appropriate Consulkit::Error subclass based on the status and response message, or nil if the response is not an error.
19 20 21 22 23 |
# File 'lib/consulkit/error.rb', line 19 def self.from_response(response) return unless (error_class = error_class_for(response)) error_class.new(response) end |
Instance Method Details
#response_body ⇒ Object
33 34 35 |
# File 'lib/consulkit/error.rb', line 33 def response_body @response.response_body end |
#response_headers ⇒ Object
29 30 31 |
# File 'lib/consulkit/error.rb', line 29 def response_headers @response.response_headers end |
#response_status ⇒ Object
25 26 27 |
# File 'lib/consulkit/error.rb', line 25 def response_status @response.status end |