Exception: Urbanairship::Common::AirshipFailure

Inherits:
StandardError
  • Object
show all
Includes:
Loggable
Defined in:
lib/urbanairship/common.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Loggable

create_logger, logger, #logger

Constructor Details

#initializeAirshipFailure

Returns a new instance of AirshipFailure.



118
119
120
121
122
123
# File 'lib/urbanairship/common.rb', line 118

def initialize
  @error = nil
  @error_code = nil
  @details = nil
  @response = nil
end

Instance Attribute Details

#detailsObject

Raised when we get an error response from the server.



116
117
118
# File 'lib/urbanairship/common.rb', line 116

def details
  @details
end

#errorObject

Raised when we get an error response from the server.



116
117
118
# File 'lib/urbanairship/common.rb', line 116

def error
  @error
end

#error_codeObject

Raised when we get an error response from the server.



116
117
118
# File 'lib/urbanairship/common.rb', line 116

def error_code
  @error_code
end

#responseObject

Raised when we get an error response from the server.



116
117
118
# File 'lib/urbanairship/common.rb', line 116

def response
  @response
end

Instance Method Details

#from_response(response) ⇒ Object

Instantiate a ValidationFailure from a Response object



126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/urbanairship/common.rb', line 126

def from_response(response)

  payload = response.body
  @error = payload['error']
  @error_code = payload['error_code']
  @details = payload['details']
  @response = response

  logger.error("Request failed with status #{response.code.to_s}: '#{@error_code} #{@error}': #{response.body}")

  self
end