Exception: Alula::AlulaError
- Inherits:
-
StandardError
- Object
- StandardError
- Alula::AlulaError
- Defined in:
- lib/alula/errors.rb
Direct Known Subclasses
ApiGatewayError, BadRequestError, ForbiddenError, InsufficientScopeError, InvalidFilterFieldError, InvalidRelationshipError, InvalidRequestError, InvalidRoleError, InvalidSortFieldError, InvalidTokenError, NotConfiguredError, NotFoundError, ProcedureError, RateLimitError, ServerError, UnknownApiError, UnknownError, ValidationError
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(error) ⇒ AlulaError
constructor
A new instance of AlulaError.
- #ok? ⇒ Boolean
Constructor Details
#initialize(error) ⇒ AlulaError
Returns a new instance of AlulaError.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/alula/errors.rb', line 7 def initialize(error) if error.class == String @message = error return end @http_status = error.http_status @raw_response = error @error = error.data['error'] @message = error.data['error_description'] || error.data['message'] end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
5 6 7 |
# File 'lib/alula/errors.rb', line 5 def error @error end |
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
5 6 7 |
# File 'lib/alula/errors.rb', line 5 def http_status @http_status end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/alula/errors.rb', line 5 def @message end |
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
5 6 7 |
# File 'lib/alula/errors.rb', line 5 def raw_response @raw_response end |
Class Method Details
.for_response(response) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/alula/errors.rb', line 23 def self.for_response(response) if !response.data['error'].nil? && !response.data['error'].empty? self.error_for_response(response) elsif !response.data['errors'].nil? && !response.data['errors'].empty? self.errors_for_response(response) elsif !response.data['message'].nil? self.error_for_response(response) elsif response.data.match(/^<!DOCTYPE html>/) self.critical_error_for_response(response.data.scan(/<pre>(.*)<\/pre>/)) elsif response.data.match(/502 Bad Gateway/) self.gateway_error_for_response(response.data.scan(/502 Bad Gateway/)) else = "Unable to derive error from response: #{response.inspect}" Alula.logger.error raise UnknownApiError.new() end rescue NoMethodError = "Unable to derive error from response: #{response.inspect}" Alula.logger.error raise UnknownApiError.new() end |
Instance Method Details
#ok? ⇒ Boolean
19 20 21 |
# File 'lib/alula/errors.rb', line 19 def ok? false end |