lib/braintree/validation_error.rb in braintree-2.90.0 vs lib/braintree/validation_error.rb in braintree-2.91.0

- old
+ new

@@ -4,11 +4,19 @@ attr_reader :attribute attr_reader :code attr_reader :message - def initialize(attributes) - set_instance_variables_from_hash attributes + 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 # :nodoc: "#<#{self.class} (#{code}) #{message}>" end