diff --git a/jsonschema_gentypes/cli.py b/jsonschema_gentypes/cli.py index 412dee98..665c90a4 100644 --- a/jsonschema_gentypes/cli.py +++ b/jsonschema_gentypes/cli.py @@ -47,6 +47,7 @@ def main() -> None: config = validate.load(args.config, json.loads(schema_data)) except validate.ValidationError as error: LOG.error(error) + config = error.data if not args.skip_config_errors: sys.exit(1) diff --git a/jsonschema_gentypes/validate.py b/jsonschema_gentypes/validate.py index 52bb991d..adff8a19 100644 --- a/jsonschema_gentypes/validate.py +++ b/jsonschema_gentypes/validate.py @@ -133,6 +133,17 @@ class ValidationError(Exception): Exception thrown on validation issue. """ + def __init__(self, message: str, data: Any) -> None: + """ + Construct. + + Arguments: + message: The error message + data: The validated data + """ + super().__init__(message) + self.data = data + def load( filename: str, @@ -153,6 +164,6 @@ def load( errors, data = validate(filename, data, schema, default) if errors: - raise ValidationError("The config file is invalid:\n{}".format("\n".join(errors))) + raise ValidationError("The config file is invalid:\n{}".format("\n".join(errors)), data) return data