Exception: MercuryParser::Error::ClientError

Inherits:
MercuryParser::Error show all
Defined in:
lib/mercury_parser/error.rb

Overview

Raised when Mercury returns a 4xx or 500 HTTP status code

Constant Summary

Constants inherited from MercuryParser::Error

ERROR_MAP

Instance Method Summary collapse

Constructor Details

#initialize(error = nil) ⇒ MercuryParser::Error::ClientError

Creates a new error from an HTTP environement

Parameters:

  • response (Hash)


13
14
15
16
17
18
19
20
21
22
# File 'lib/mercury_parser/error.rb', line 13

def initialize(error = nil)
  parsed_error = parse_error(error)
  http_error = error.response[:status].to_i

  if ERROR_MAP.has_key?(http_error)
    raise ERROR_MAP[http_error].new(parsed_error[:messages])
  else
    super
  end
end