forked from OpenJobDescription/openjd-model-for-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_errors.py
More file actions
54 lines (38 loc) · 1.47 KB
/
_errors.py
File metadata and controls
54 lines (38 loc) · 1.47 KB
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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
__all__ = [
"CompatibilityError",
"DecodeValidationError",
"ExpressionError",
"ModelValidationError",
"TokenError",
"UnsupportedSchema",
]
class UnsupportedSchema(ValueError):
"""Error raised when an attempt is made to decode a template with
an unknown or otherwise nonvalid schema identification.
"""
_version: str
def __init__(self, version: str):
self._version = version
super().__init__(f"Unsupported schema version: {self._version}")
class DecodeValidationError(ValueError):
"""Error raised when an decoding error is encountered while decoding
a template.
"""
class ModelValidationError(ValueError):
"""Error raised when a validation error is encountered while validating
a model.
"""
class ExpressionError(ValueError):
"""Error raised when there is an error in the form of an expression that is being
parsed.
"""
class TokenError(ExpressionError):
"""Error raised when performing lexical analysis on an expression for parsing."""
def __init__(self, expression: str, token_value: str, position: int):
msg = f"Unexpected '{token_value}' in '{expression}' after '{expression[:position]}'"
super().__init__(msg)
class CompatibilityError(ValueError):
"""Error raised when a check that two, or more, models are compatible determines that
there are non-compatibilities between the models.
"""