Exception: ChangeHealth::ChangeHealthException
- Inherits:
-
StandardError
- Object
- StandardError
- ChangeHealth::ChangeHealthException
- Defined in:
- lib/change_health/change_health_exception.rb
Class Method Summary collapse
Class Method Details
.from_response(response, msg: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/change_health/change_health_exception.rb', line 5 def self.from_response(response, msg: nil) error_msg = nil begin error_msg = parse_error_msg(response.parsed_response) rescue JSON::ParserError error_msg = response.body end ChangeHealthException.new("Failed #{msg}: HTTP code: #{response&.code} MSG: #{error_msg}") end |
.parse_error_msg(error_response) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/change_health/change_health_exception.rb', line 17 def self.parse_error_msg(error_response) if error_response.is_a?(Hash) && error_response.include?('error_description') error_response['error_description'] else error_response end end |