class Some_Error(RuntimeError):
def __init__(self, error_str: str = ""):
super().__init__(f"{error_str}")
class ErrorBase(Exception):
def __init__(self, description: str) -> None:
Exception.__init__(self)
self._description = description
def description(self) -> str:
return self._description
class SomeOtherError(ErrorBase):
def __init__(self, description: str) -> None:
ErrorBase.__init__(self, description)
def try_except():
try:
raise Some_Error("error string")
except Some_Error as error:
raise SomeOtherError("Some other error") from error
def run_it():
try:
try_except()
except SomeOtherError as error:
print(f"SomeOtherError message: {error.description()}")