Source code for mapstp.exceptions

"""Utility module to specify exception hierarchy for all tee package."""

from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    import pandas as pd


[docs] class MyError(ValueError): """Base class for exceptions in the `mapstp` package."""
[docs] class FileError(MyError): """STP parser file format error."""
[docs] class STPParserError(MyError): """STP parser syntax error."""
[docs] def __init__(self: STPParserError, message: str = "The STP is invalid") -> None: """Create STP parsing specific exception. Args: message: explanation, what happened """ super().__init__(self, message)
[docs] class PathInfoError(MyError): """Error on extracting information for labels specified in STP paths."""
[docs] def __init__(self: PathInfoError, message: str, row: int, path_info: pd.DataFrame) -> None: """Create exception object with information on location in path_info caused the error. Args: message: explanation, what happened row: row in path_info table path_info: the path_info table """ MyError.__init__(self, message + f" Row #{row}:\n" + f"{path_info.iloc[row].to_dict()}")