Skip to content

Commit

Permalink
add back validator_error_message (#6465)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmyoop authored Dec 20, 2022
1 parent 1e35339 commit c39ea80
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/dbt/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2362,3 +2362,14 @@ def materialization_not_available(model, adapter_type):
def macro_not_found(model, target_macro_id):
msg = f"'{model.unique_id}' references macro '{target_macro_id}' which is not defined!"
raise CompilationException(msg=msg, node=model)


# adapters use this to format messages. it should be deprecated but live on for now
def validator_error_message(exc):
"""Given a dbt.dataclass_schema.ValidationError (which is basically a
jsonschema.ValidationError), return the relevant parts as a string
"""
if not isinstance(exc, dbt.dataclass_schema.ValidationError):
return str(exc)
path = "[%s]" % "][".join(map(repr, exc.relative_path))
return "at path {}: {}".format(path, exc.message)

0 comments on commit c39ea80

Please sign in to comment.