Sha256: 21262587c5de677720123a705f1799096c4ef4c460ecdec622f9c65f055e7377

Contents?: true

Size: 728 Bytes

Versions: 1

Compression:

Stored size: 728 Bytes

Contents

module Mollie
  class Exception < StandardError
  end

  class RequestError < Mollie::Exception
    attr_accessor :status, :title, :detail, :field, :links

    def initialize(error, response = nil)
      exception.status = error['status']
      exception.title  = error['title']
      exception.detail = error['detail']
      exception.field  = error['field']
      exception.links  = error['_links']
      self.response = response
    end

    def to_s
      "#{status} #{title}: #{detail}"
    end

    def http_headers
      response.to_hash if response
    end

    def http_body
      response.body if response
    end

    private

    attr_accessor :response
  end

  class ResourceNotFoundError < RequestError
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mollie-api-ruby-4.14.0 lib/mollie/exception.rb