class Postmark::HttpServerError

Attributes

body[RW]
full_response[RW]
parsed_body[RW]
status_code[RW]

Public Class Methods

build(status_code, body) click to toggle source
# File lib/postmark/error.rb, line 17
def self.build(status_code, body)
  parsed_body = Postmark::Json.decode(body) rescue {}

  case status_code
  when '401'
    InvalidApiKeyError.new(401, body, parsed_body)
  when '422'
    ApiInputError.build(body, parsed_body)
  when '500'
    InternalServerError.new(500, body, parsed_body)
  else
    UnexpectedHttpResponseError.new(status_code, body, parsed_body)
  end
end
new(status_code = 500, body = '', parsed_body = {}) click to toggle source
Calls superclass method
# File lib/postmark/error.rb, line 32
def initialize(status_code = 500, body = '', parsed_body = {})
  self.parsed_body = parsed_body
  self.status_code = status_code.to_i
  self.body = body
  message = parsed_body.fetch('Message', "The Postmark API responded with HTTP status #{status_code}.")

  super(message)
end

Public Instance Methods

retry?() click to toggle source
# File lib/postmark/error.rb, line 41
def retry?
  5 == status_code / 100
end