Exception: Postmark::ApiInputError

Inherits:
HttpServerError show all
Defined in:
lib/postmark/error.rb

Constant Summary collapse

INACTIVE_RECIPIENT =
406
INVALID_EMAIL_REQUEST =
300

Instance Attribute Summary collapse

Attributes inherited from HttpServerError

#body, #parsed_body, #status_code

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_code = nil, body = '', parsed_body = {}) ⇒ ApiInputError

Returns a new instance of ApiInputError.



65
66
67
68
# File 'lib/postmark/error.rb', line 65

def initialize(error_code = nil, body = '', parsed_body = {})
  self.error_code = error_code.to_i
  super(422, body, parsed_body)
end

Instance Attribute Details

#error_codeObject

Returns the value of attribute error_code.



50
51
52
# File 'lib/postmark/error.rb', line 50

def error_code
  @error_code
end

Class Method Details

.build(body, parsed_body) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/postmark/error.rb', line 52

def self.build(body, parsed_body)
  error_code = parsed_body['ErrorCode'].to_i

  case error_code
  when INACTIVE_RECIPIENT
    InactiveRecipientError.new(error_code, body, parsed_body)
  when INVALID_EMAIL_REQUEST
    InvalidEmailRequestError.new(error_code, body, parsed_body)
  else
    new(error_code, body, parsed_body)
  end
end

Instance Method Details

#retry?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/postmark/error.rb', line 70

def retry?
  false
end