Sha256: 05c681a86fcb01382a52e1786ab4c9229ad5b544fbf7f24c38468dd70d9c7e6d

Contents?: true

Size: 637 Bytes

Versions: 8

Compression:

Stored size: 637 Bytes

Contents

module Braintree
  class ValidationError
    include BaseModule

    attr_reader :attribute
    attr_reader :code
    attr_reader :message

    def initialize(error_hash)
      # parse GraphQL response objects
      if (error_hash[:extensions] &&
          error_hash[:extensions][:errorClass] &&
          error_hash[:extensions][:errorClass] == "VALIDATION")
        error_hash[:code] = error_hash[:extensions][:legacyCode].to_i
        error_hash[:attribute] = error_hash[:path].last
      end

      set_instance_variables_from_hash error_hash
    end

    def inspect
      "#<#{self.class} (#{code}) #{message}>"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
braintree-4.23.0 lib/braintree/validation_error.rb
braintree-4.22.0 lib/braintree/validation_error.rb
braintree-4.21.0 lib/braintree/validation_error.rb
braintree-4.20.0 lib/braintree/validation_error.rb
braintree-4.19.0 lib/braintree/validation_error.rb
braintree-4.18.0 lib/braintree/validation_error.rb
braintree-4.17.0 lib/braintree/validation_error.rb
braintree-4.16.0 lib/braintree/validation_error.rb