class Findface::Error

Attributes

parsed_response[R]

Public Class Methods

error_message(code, parsed_response) click to toggle source

Method to return error message based on the response code

# File lib/findface/error.rb, line 13
def self.error_message(code, parsed_response)
  case code
    when 400 then
      "Bad parameters supplied"
    when 401 then
      'Wrong authentication token or no token at all is provided.'
    when 403 then
      "Not authorized. You don't have permission to take action on a particular resource"
    when 404 then
      'Resource was not found'
    when 422 then
      "This usually means you are missing or have supplied invalid parameters for a request: #{parsed_response}"
    when 500 then
      "Internal server error. Something went wrong. This is a bug. Please report it to support immediately"
    else
      'An error occured. Please check parsed_response for details'
  end
end
new(parsed_response, code) click to toggle source

Contructor method to take response code and parsed_response. The method gives a set of object methods in rescue - e.message and e.parsed_response

Calls superclass method
# File lib/findface/error.rb, line 7
def initialize(parsed_response, code)
  super(Findface::Error.error_message(code, parsed_response))
  @parsed_response = parsed_response
end