Exception: Databasedotcom::SalesForceError
- Inherits:
-
StandardError
- Object
- StandardError
- Databasedotcom::SalesForceError
- Defined in:
- lib/databasedotcom/sales_force_error.rb
Overview
An exception raised when any non successful request is made to Force.com.
Instance Attribute Summary collapse
-
#error_code ⇒ Object
the
errorCode
from the server response body. -
#response ⇒ Object
the Net::HTTPResponse from the API call.
Instance Method Summary collapse
-
#initialize(response) ⇒ SalesForceError
constructor
A new instance of SalesForceError.
Constructor Details
#initialize(response) ⇒ SalesForceError
Returns a new instance of SalesForceError.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/databasedotcom/sales_force_error.rb', line 9 def initialize(response) self.response = response parsed_body = JSON.parse(response.body) rescue nil if parsed_body if parsed_body.is_a?(Array) = parsed_body[0]["message"] self.error_code = parsed_body[0]["errorCode"] else = parsed_body["error_description"] self.error_code = parsed_body["error"] end else = response.body end super() end |
Instance Attribute Details
#error_code ⇒ Object
the errorCode
from the server response body
7 8 9 |
# File 'lib/databasedotcom/sales_force_error.rb', line 7 def error_code @error_code end |
#response ⇒ Object
the Net::HTTPResponse from the API call
5 6 7 |
# File 'lib/databasedotcom/sales_force_error.rb', line 5 def response @response end |