Exception: Findface::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Findface::Error
- Defined in:
- lib/findface/error.rb
Instance Attribute Summary collapse
-
#parsed_response ⇒ Object
readonly
Returns the value of attribute parsed_response.
Class Method Summary collapse
-
.error_message(code, parsed_response) ⇒ Object
Method to return error message based on the response code.
Instance Method Summary collapse
-
#initialize(parsed_response, code) ⇒ Error
constructor
Contructor method to take response code and parsed_response.
Constructor Details
#initialize(parsed_response, code) ⇒ Error
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
7 8 9 10 |
# File 'lib/findface/error.rb', line 7 def initialize(parsed_response, code) super(Findface::Error.(code, parsed_response)) @parsed_response = parsed_response end |
Instance Attribute Details
#parsed_response ⇒ Object (readonly)
Returns the value of attribute parsed_response.
3 4 5 |
# File 'lib/findface/error.rb', line 3 def parsed_response @parsed_response end |
Class Method Details
.error_message(code, parsed_response) ⇒ Object
Method to return error message based on the response code
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/findface/error.rb', line 13 def self.(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 |