diff --git a/jsonschema/validators.py b/jsonschema/validators.py index 1dc420c70..7090f73da 100644 --- a/jsonschema/validators.py +++ b/jsonschema/validators.py @@ -326,7 +326,6 @@ def iter_errors(self, instance, _schema=None): errors = validator(self, v, instance, _schema) or () for error in errors: - # set details if not already set by the called fn error._set( validator=k, validator_value=v, @@ -349,8 +348,15 @@ def descend(self, instance, schema, path=None, schema_path=None): yield error def validate(self, *args, **kwargs): - for error in self.iter_errors(*args, **kwargs): - raise error + errors = self.iter_errors(*args, **kwargs) + matched_errors = exceptions.best_match(errors) + error_dict = {} + error_message = None + if matched_errors: + error_dict['key'] = list(matched_errors.path)[-1] + error_dict['message'] = matched_errors.message + error_message = "Schema Error! " + str(error_dict) + return error_message def is_type(self, instance, type): try: