Skip to content

Commit

Permalink
small formatting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
solarw committed Feb 15, 2023
1 parent 5fd694b commit d0c1702
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion aea/configurations/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,17 @@ def _validate(self, instance: Dict) -> None:
errors: List[jsonschema.ValidationError] = list(
self._validator.iter_errors(instance=instance)
)

if len(errors) > 0:
error = errors[0]
# raise Exception(error.__dict__)
error_msg = self._build_message_from_errors(errors)
raise AEAValidationError(f"{error_msg}")

@staticmethod
def _build_message_from_errors(errors: List[jsonschema.ValidationError]) -> str:
"""Build an error message from validation errors."""
path = lambda error: ".".join(list(error.path)) # noqa # type: ignore
path = lambda error: "::".join(map(str, error.path)) # noqa # type: ignore
result = [f"{path(error)}: {error.message}" for error in errors]
return "The following errors occurred during validation:\n - " + "\n - ".join(
result
Expand Down

0 comments on commit d0c1702

Please sign in to comment.