Sha256: ed83476b09850e210a789ce98d8273b7dc2f8a509b1dad4c43fec14de22b6966

Contents?: true

Size: 733 Bytes

Versions: 1

Compression:

Stored size: 733 Bytes

Contents

=begin
The class will handle response failures coming from Onfido
It's main purpose is to produce meaningful error messages to the user e.g.

  RequestError: Authorization error: please re-check your credentials

Users can also rescue the error and insect its type and affected fields as
specified in the Onfido documentation e.g.

  begin
    # error being raised
  rescue Onfido::RequestError => e
    e.type
    e.fields
  end

=end

module Onfido
  class RequestError < StandardError
    attr_accessor :type, :fields, :response_code

    def initialize(message=nil, type: nil, fields: nil, response_code: nil)
      @type = type
      @fields = fields
      @response_code = response_code

      super(message)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
onfido-0.0.4 lib/onfido/errors/request_error.rb