-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy patherrors.py
More file actions
46 lines (31 loc) · 1.16 KB
/
errors.py
File metadata and controls
46 lines (31 loc) · 1.16 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
from __future__ import annotations
from pybind11_stubgen.structs import Identifier, QualifiedName
class ParserError(Exception):
pass
class InvalidIdentifierError(ParserError):
def __init__(self, name: Identifier, found_at: QualifiedName):
super().__init__()
self.name = name
self.at = found_at
def __str__(self):
return f"Invalid identifier '{self.name}' at '{self.at}'"
class InvalidExpressionError(ParserError):
def __init__(self, expression: str):
super().__init__()
self.expression: str = expression
def __str__(self):
return f"Invalid expression '{self.expression}'"
class NameResolutionError(ParserError):
def __init__(self, name: QualifiedName):
super().__init__()
self.name = name
def __str__(self):
return f"Can't find/import '{self.name}'"
class InspectError(ParserError):
def __init__(self, path: QualifiedName, class_: type, msg: str):
super().__init__()
self.path = path
self.class_ = class_
self.msg = msg
def __str__(self):
return f"Can't get members of type {self.class_} at {self.path}: {self.msg}"