Sha256: 15d8c31d7982b32719328b7b73b28854e0d4b6c3ba2922589fe51f3ee8b0a809

Contents?: true

Size: 647 Bytes

Versions: 16

Compression:

Stored size: 647 Bytes

Contents

module EasyPost
  class Error < StandardError
    attr_reader :message
    attr_reader :http_status
    attr_reader :http_body
    attr_reader :json_body
    attr_reader :param

    def initialize(message=nil, http_status=nil, http_body=nil, json_body=nil)
      @message = message
      @http_status = http_status
      @http_body = http_body
      @json_body = json_body

      begin
        @param = @json_body[:error][:param]
      rescue
        @param = nil
      end

      super(message)
    end

    def to_s
      status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
      "#{status_string}#{@message}"
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
easypost-2.1.1 lib/easypost/error.rb
easypost-2.0.15 lib/easypost/error.rb
easypost-2.1.0 lib/easypost/error.rb
easypost-2.0.13 lib/easypost/error.rb
easypost-2.0.12 lib/easypost/error.rb
easypost-2.0.11 lib/easypost/error.rb
easypost-2.0.10 lib/easypost/error.rb
easypost-2.0.9 lib/easypost/error.rb
easypost-2.0.8 lib/easypost/error.rb
easypost-2.0.7 lib/easypost/error.rb
easypost-2.0.6 lib/easypost/error.rb
easypost-2.0.5 lib/easypost/error.rb
easypost-2.0.3 lib/easypost/error.rb
easypost-2.0.2 lib/easypost/error.rb
easypost-2.0.1 lib/easypost/error.rb
easypost-2.0.0 lib/easypost/error.rb