class Levelup::Responses::Error
Encapsulates a response to an unsuccessful request.
Attributes
errors[R]
An array of error hashes with the properties 'object' (the LevelUp API object causing the error), 'property' (the property of that object causing the error), and 'message' (a human-readable error message).
headers[R]
Any HTTP headers returned by the API, in hash form.
status_code[R]
The HTTP status code returned by the API
Public Class Methods
new(headers, errors, status_code)
click to toggle source
Builds the error from the raw JSON response and the specified status code.
# File lib/levelup/responses/error.rb, line 16 def initialize(headers, errors, status_code) @headers = headers if errors.is_a?(Array) || !errors @errors = (errors || []).map do |error| OpenStruct.new(error['error']) end else @errors = [OpenStruct.new(message: 'The API returned an unexpected '\ 'response. This is likely due to an incorrectly defined base URL.')] end @status_code = status_code end
Public Instance Methods
success?()
click to toggle source
Errors
are always unsuccessful.
# File lib/levelup/responses/error.rb, line 32 def success? false end