Exception: DataSiftError
- Inherits:
-
StandardError
- Object
- StandardError
- DataSiftError
- Defined in:
- lib/errors.rb
Overview
Custom error class for rescuing DataSift errors
Direct Known Subclasses
ApiResourceNotFoundError, AuthError, BadGatewayError, BadParametersError, BadRequestError, ConflictError, ConnectionError, ForbiddenError, GatewayTimeoutError, GoneError, InternalServerError, InvalidConfigError, InvalidParamError, InvalidTypeError, MethodNotAllowedError, NotConfiguredError, NotConnectedError, NotSupportedError, PayloadTooLargeError, PreconditionFailedError, ReconnectTimeoutError, ServiceUnavailableError, StreamingMessageError, TooManyRequestsError, UnprocessableEntityError, UnsupportedMediaTypeError, WebSocketOnWindowsError
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(http_status = nil, http_body = nil, response_on_error = nil) ⇒ DataSiftError
constructor
A new instance of DataSiftError.
- #message ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(http_status = nil, http_body = nil, response_on_error = nil) ⇒ DataSiftError
Returns a new instance of DataSiftError.
5 6 7 8 9 |
# File 'lib/errors.rb', line 5 def initialize(http_status = nil, http_body = nil, response_on_error = nil) @status = http_status @body = http_body @response = response_on_error end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/errors.rb', line 3 def body @body end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/errors.rb', line 3 def response @response end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/errors.rb', line 3 def status @status end |
Instance Method Details
#message ⇒ Object
11 12 13 |
# File 'lib/errors.rb', line 11 def @body.nil? ? @status : @body end |
#to_s ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/errors.rb', line 15 def to_s # If both body and status were provided then message is the body otherwise # the status contains the message msg = !@body.nil? && !@status.nil? ? @body : @status # If body is nil then status is the message body so no status is included status_string = @body.nil? ? '' : "(Status #{@status}) " "#{status_string} : #{msg}" end |