class DataSiftError

Custom error class for rescuing DataSift errors

Attributes

body[R]
response[R]
status[R]

Public Class Methods

new(http_status = nil, http_body = nil, response_on_error = nil) click to toggle source
# 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

Public Instance Methods

message() click to toggle source
# File lib/errors.rb, line 11
def message
  @body.nil? ? @status : @body
end
to_s() click to toggle source
# 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