-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
exception.py
91 lines (63 loc) · 1.79 KB
/
exception.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
class SqlfmtError(ValueError):
"""
Generic class for an error encountered when formatting
user code. Should be caught by api.run for display to the
user.
"""
def __str__(self) -> str:
intro = "sqlfmt encountered an error: "
message = super().__str__()
return f"{intro}{message}"
class SqlfmtConfigError(SqlfmtError):
"""
Raised during opening or parsing a pyproject.toml file
"""
pass
class SqlfmtUnicodeError(SqlfmtError):
"""
Raised while reading input if the input cannot be
decoded into a Python string
"""
pass
class SqlfmtParsingError(SqlfmtError):
"""
Raised during lexing if sqlfmt encounters a token that does
not match any rules
"""
pass
class SqlfmtBracketError(SqlfmtError):
"""
Raised during lexing if sqlfmt encounters mismatched, unterminated,
or unexpected closing brackets
"""
pass
class SqlfmtSegmentError(SqlfmtError):
"""
Raised during merging if a segment is unexpectedly empty
"""
pass
class SqlfmtEquivalenceError(SqlfmtError):
"""
Raised during the safety check if the result query does
not lex to the same tokens as the raw query
"""
pass
class SqlfmtControlFlowException(Exception):
"""
Generic exception for exceptions used to manage control
flow. Should always be caught by the application and
never raised back to the user
"""
pass
class StopRulesetLexing(SqlfmtControlFlowException):
"""
Raised by the Analyzer or one of its actions to indicate
that further lexing should use the previous ruleset
"""
pass
class CannotMergeException(SqlfmtControlFlowException):
"""
Raised by the merger if the passed lines cannot be merged
for any reason
"""
pass