Exception: FacebookCommerce::Api::UnexpectedHttpResponse
- Inherits:
-
StandardError
- Object
- StandardError
- FacebookCommerce::Api::UnexpectedHttpResponse
- Defined in:
- lib/facebook_commerce.rb
Instance Method Summary collapse
-
#initialize(response) ⇒ UnexpectedHttpResponse
constructor
A new instance of UnexpectedHttpResponse.
Constructor Details
#initialize(response) ⇒ UnexpectedHttpResponse
Returns a new instance of UnexpectedHttpResponse.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/facebook_commerce.rb', line 24 def initialize(response) = response. || response.code # Try to extract error_user_msg from Facebook API response if response.body && !response.body.empty? begin parsed_body = JSON.parse(response.body) error_user_msg = parsed_body.dig('error', 'error_user_msg') if error_user_msg = "#{message}: #{error_user_msg}" end rescue JSON::ParserError # If JSON parsing fails, just use the original message end end super end |