errors.py¶
clew/guard/errors.py
Typed exceptions for clew guard.
__init__
None clew.guard.errors.GuardError.__init__(self, str message, list[str]|None problems=None)
Build an error carrying one or more human-readable problem descriptions.
Source · 5 lines
def __init__(self, message: str, problems: list[str] | None = None) -> None:
super().__init__(message)
self.message = message
self.problems: list[str] = problems or []
Activity · 3 steps
Requirements
__str__
str clew.guard.errors.GuardError.__str__(self)
Render the full detail, so a caller printing str(e) sees every problem.
Source · 4 lines
def __str__(self) -> str:
return self.details()
Activity · 1 steps
Requirements
details
str clew.guard.errors.GuardError.details(self)
Render the message followed by each individual problem.
Source · 3 lines
def details(self) -> str:
return "\n".join([self.message, *self.problems])