Error Bubbling: Implement machine-readable rich error objects for CRUD operations

This commit is contained in:
Scott Idem
2026-01-19 17:01:58 -05:00
parent 19e64135ca
commit eeb19647f5
4 changed files with 70 additions and 13 deletions

View File

@@ -0,0 +1,23 @@
from typing import Optional, Any, Dict
from pydantic import BaseModel, Field
class StandardError(BaseModel):
"""
Standardized machine-readable error structure for Aether.
Helps the frontend decide how to handle failures.
"""
category: str = Field(..., description="Error category (e.g., 'database', 'validation', 'security')")
code: Optional[int] = Field(None, description="Specific error code (e.g., MariaDB error code)")
message: str = Field(..., description="Developer-friendly error message")
recoverable: bool = Field(False, description="If True, the frontend might want to retry or ask for user input")
details: Optional[Any] = Field(None, description="Raw technical details or traceback (if permitted)")
class Config:
schema_extra = {
"example": {
"category": "database",
"code": 1062,
"message": "Duplicate entry for key 'id_random'",
"recoverable": False
}
}