Skip to content

Exceptions

exceptions

FrontendProgramException dataclass

Bases: Exception

Exception type used when something goes wrong with FrontendProgram.

Source code in xdsl/frontend/pyast/utils/exceptions.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
@dataclass
class FrontendProgramException(Exception):
    """
    Exception type used when something goes wrong with `FrontendProgram`.
    """

    msg: str

    def __init__(self, msg: str):
        super().__init__()
        self.msg = msg

    def __str__(self) -> str:
        return f"{self.msg}"

msg: str = msg instance-attribute

__init__(msg: str)

Source code in xdsl/frontend/pyast/utils/exceptions.py
12
13
14
def __init__(self, msg: str):
    super().__init__()
    self.msg = msg

__str__() -> str

Source code in xdsl/frontend/pyast/utils/exceptions.py
16
17
def __str__(self) -> str:
    return f"{self.msg}"

CodeGenerationException dataclass

Bases: FrontendProgramException

Exception type used when xDSL code generation fails. Should be used for user-facing errors, e.g. unsupported functionality or failed type checks.

Source code in xdsl/frontend/pyast/utils/exceptions.py
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
@dataclass
class CodeGenerationException(FrontendProgramException):
    """
    Exception type used when xDSL code generation fails. Should be used for
    user-facing errors, e.g. unsupported functionality or failed type checks.
    """

    file: str | None
    line: int
    col: int

    def __init__(
        self,
        file: str | None,
        line: int,
        col: int,
        msg: str,
    ):
        super().__init__(msg)
        self.file = file
        self.line = line
        self.col = col

    def __str__(self) -> str:
        str = "Code generation exception at "
        if self.file:
            return (
                str + f'"{self.file}", line {self.line} column {self.col}: {self.msg}'
            )
        else:
            return str + f"line {self.line} column {self.col}: {self.msg}"

file: str | None = file instance-attribute

line: int = line instance-attribute

col: int = col instance-attribute

__init__(file: str | None, line: int, col: int, msg: str)

Source code in xdsl/frontend/pyast/utils/exceptions.py
31
32
33
34
35
36
37
38
39
40
41
def __init__(
    self,
    file: str | None,
    line: int,
    col: int,
    msg: str,
):
    super().__init__(msg)
    self.file = file
    self.line = line
    self.col = col

__str__() -> str

Source code in xdsl/frontend/pyast/utils/exceptions.py
43
44
45
46
47
48
49
50
def __str__(self) -> str:
    str = "Code generation exception at "
    if self.file:
        return (
            str + f'"{self.file}", line {self.line} column {self.col}: {self.msg}'
        )
    else:
        return str + f"line {self.line} column {self.col}: {self.msg}"