Exception: Redox::RedoxException
- Inherits:
-
StandardError
- Object
- StandardError
- Redox::RedoxException
- Defined in:
- lib/redox/redox_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/redox/redox_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 RedoxException.new("Failed #{msg}: HTTP code: #{response&.code} MSG: #{error_msg}") end |
.parse_error_msg(error_response) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/redox/redox_exception.rb', line 17 def self.parse_error_msg(error_response) error_list = error_response&.[]('Meta')&.[]('Errors') if error_list error_list.map { |el| el['Text'] || el.to_s }.join('|') else error_response.to_s end end |