generated from coulomb/repo-seed
Initial implementation
This commit is contained in:
25
src/infospace_bench/errors.py
Normal file
25
src/infospace_bench/errors.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any
|
||||
|
||||
|
||||
@dataclass
|
||||
class InfospaceError(Exception):
|
||||
"""Structured application error suitable for CLI and API surfaces."""
|
||||
|
||||
code: str
|
||||
message: str
|
||||
detail: dict[str, Any] = field(default_factory=dict)
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
super().__init__(self.message)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
return {
|
||||
"error": {
|
||||
"code": self.code,
|
||||
"message": self.message,
|
||||
"detail": self.detail,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user