class EasyPost::Error

EasyPost Error object.

Attributes

code[R]
errors[R]
http_body[R]
message[R]
status[R]

Public Class Methods

new(message = nil, status = nil, code = nil, errors = nil, http_body = nil) click to toggle source

Initialize a new EasyPost Error

Calls superclass method
# File lib/easypost/error.rb, line 8
def initialize(message = nil, status = nil, code = nil, errors = nil, http_body = nil)
  # message should be a string but can sometimes incorrectly come back as an array
  @message = message.is_a?(Array) ? message.join(', ') : message
  @status = status
  @code = code
  @errors = errors
  @http_body = http_body

  super(message)
end

Public Instance Methods

==(other) click to toggle source

Compare error properties.

# File lib/easypost/error.rb, line 25
def ==(other)
  other.is_a?(EasyPost::Error) &&
    message == other.message &&
    status == other.status &&
    code == other.code &&
    errors == other.errors
end
to_s() click to toggle source

Convert an error to a string.

# File lib/easypost/error.rb, line 20
def to_s
  "#{code} (#{status}): #{message} #{errors}".strip
end