diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-09-15 16:46:17 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-09-15 16:46:17 +0000 |
commit | 28cc22419e32a65fea2d1678400265b8cabc3aff (patch) | |
tree | ff9ac1991fd48490b21ef6aa9015a347a165e2d9 /sqlglot/errors.py | |
parent | Initial commit. (diff) | |
download | sqlglot-28cc22419e32a65fea2d1678400265b8cabc3aff.tar.xz sqlglot-28cc22419e32a65fea2d1678400265b8cabc3aff.zip |
Adding upstream version 6.0.4.upstream/6.0.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/errors.py')
-rw-r--r-- | sqlglot/errors.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sqlglot/errors.py b/sqlglot/errors.py new file mode 100644 index 0000000..89aa935 --- /dev/null +++ b/sqlglot/errors.py @@ -0,0 +1,38 @@ +from enum import auto + +from sqlglot.helper import AutoName + + +class ErrorLevel(AutoName): + IGNORE = auto() # Ignore any parser errors + WARN = auto() # Log any parser errors with ERROR level + RAISE = auto() # Collect all parser errors and raise a single exception + IMMEDIATE = auto() # Immediately raise an exception on the first parser error + + +class SqlglotError(Exception): + pass + + +class UnsupportedError(SqlglotError): + pass + + +class ParseError(SqlglotError): + pass + + +class TokenError(SqlglotError): + pass + + +class OptimizeError(SqlglotError): + pass + + +def concat_errors(errors, maximum): + msg = [str(e) for e in errors[:maximum]] + remaining = len(errors) - maximum + if remaining > 0: + msg.append(f"... and {remaining} more") + return "\n\n".join(msg) |