aboutsummaryrefslogtreecommitdiff
path: root/tools/cru-py/cru/error.py
blob: 95edbd30d46848b74f273cb40ae49daaafc84979 (plain)
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
from typing import NoReturn


class CruException(Exception):
    """Base exception class of all exceptions in cru."""


class CruUnreachableError(CruException):
    """Raised when a code path is unreachable."""


def cru_unreachable() -> NoReturn:
    raise CruUnreachableError()


class CruInternalError(CruException):
    """Raised when an internal logic error occurs."""


class UserFriendlyException(CruException):
    def __init__(self, message: str, user_message: str, *args, **kwargs) -> None:
        super().__init__(message, *args, **kwargs)
        self._user_message = user_message

    @property
    def user_message(self) -> str:
        return self._user_message