Sha256: 9d887cde4f87b960e04a54367e1d5d9ddcec004691c1886e71f2ae729eeffd2f

Contents?: true

Size: 613 Bytes

Versions: 24

Compression:

Stored size: 613 Bytes

Contents

module Onfido
  class OnfidoError < StandardError
    attr_accessor :response_code, :response_body

    def initialize(message = nil,
                   response_code: nil,
                   response_body: nil)
      @response_code = response_code
      @response_body = response_body

      super(message)
    end

    def json_body
      JSON.parse(response_body.to_s)
    rescue JSON::ParserError
      nil
    end

    def type
      json_body && json_body['error'] && json_body['error']['type']
    end

    def fields
      json_body && json_body['error'] && json_body['error']['fields']
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
onfido-1.1.1 lib/onfido/errors/onfido_error.rb
onfido-0.15.1 lib/onfido/errors/onfido_error.rb
onfido-1.1.0 lib/onfido/errors/onfido_error.rb
onfido-1.0.0 lib/onfido/errors/onfido_error.rb
onfido-0.15.0 lib/onfido/errors/onfido_error.rb
onfido-0.14.0 lib/onfido/errors/onfido_error.rb
onfido-0.13.0 lib/onfido/errors/onfido_error.rb
onfido-0.12.0 lib/onfido/errors/onfido_error.rb
onfido-0.11.0 lib/onfido/errors/onfido_error.rb
onfido-0.10.0 lib/onfido/errors/onfido_error.rb
onfido-0.9.0 lib/onfido/errors/onfido_error.rb
onfido-0.8.4 lib/onfido/errors/onfido_error.rb
onfido-0.8.3 lib/onfido/errors/onfido_error.rb
onfido-0.8.2 lib/onfido/errors/onfido_error.rb
onfido-0.8.1 lib/onfido/errors/onfido_error.rb
onfido-0.7.1 lib/onfido/errors/onfido_error.rb
onfido-0.7.0 lib/onfido/errors/onfido_error.rb
onfido-0.6.1 lib/onfido/errors/onfido_error.rb
onfido-0.6.0 lib/onfido/errors/onfido_error.rb
onfido-0.5.0 lib/onfido/errors/onfido_error.rb