Exception: Wazuh::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Wazuh::Error
- Defined in:
- lib/wazuh/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
-
#initialize(response) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(response) ⇒ Error
Returns a new instance of Error.
19 20 21 22 |
# File 'lib/wazuh/error.rb', line 19 def initialize(response) @response = response super() end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/wazuh/error.rb', line 3 def response @response end |
Class Method Details
.from_response(response) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/wazuh/error.rb', line 5 def self.from_response(response) status = response.status.to_i klass = case status when 400 then BadRequest when 400..499 then ClientError when 500 then InternalServerError when 500..599 then ServerError end raise response.body["message"] if response.body["error"] != 0 klass.new(response) if klass end |