1"""Stable failure metadata, independent of human-readable exception text."""
3from __future__
import annotations
9 """Exception base preserving legacy types and exposing typed failure args.
11 ``str(error)`` and ``error.args`` retain the legacy message contract.
12 ``error.failure_args`` is the scalar JSON object used by the failure protocol.
15 code: str |
None =
"hpo_unclassified_error"
20 arguments = getattr(self,
"_failure_args", {})
21 return dict(arguments)
if arguments
is not None else None
24 self, code: str |
None, args: dict[str, Any] |
None, origin: str =
"hpo"
37 "origin": getattr(error,
"origin",
"hpo"),
38 "code": getattr(error,
"code",
"hpo_unclassified_error"),
39 "args": error.failure_args
if isinstance(error, HpoError)
else {},
40 "exit_code": exit_code,
with_failure(self, str|None code, dict[str, Any]|None args, str origin="hpo")
dict[str, Any]|None failure_args(self)
dict[str, Any] failure_document(BaseException error, int exit_code)