Exception: MercuryWebParser::Error::ClientError

Inherits:
MercuryWebParser::Error show all
Defined in:
lib/mercury_web_parser/error.rb

Overview

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

Constant Summary

Constants inherited from MercuryWebParser::Error

ERROR_MAP

Instance Method Summary collapse

Constructor Details

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

Creates a new error from an HTTP environement

Parameters:

  • response (Hash)


9
10
11
12
13
14
15
16
17
# File 'lib/mercury_web_parser/error.rb', line 9

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

  if ERROR_MAP.key?(http_error)
    raise ERROR_MAP[http_error], error.response[:body]['message']
  end

  super
end