generated from coulomb/repo-seed
26 lines
607 B
Python
26 lines
607 B
Python
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,
|
|
}
|
|
}
|