Summary
Aegis returns generic error objects across all endpoints. Claude Code categorizes errors into UserError, ToolError, and SystemError with retry logic, error codes, and actionable messages.
CC Reference
src/utils/errors.ts — Error class hierarchy
src/utils/toolErrors.ts — Tool-specific error formatting
src/services/tools/toolHooks.ts — Error handling in tool execution flow
src/types/permissions.ts — PermissionError types
CC Architecture
- Error hierarchy:
UserError (user input), ToolError (tool execution), SystemError (infrastructure)
- Each error has:
code, message, retryable, suggestions[], context{}
- Tool errors include the tool name, input, and whether the output can be modified by hooks
- Permission errors carry
decisionReason and blockedPath
Current Aegis Gap
- Aegis uses plain
{error: string, code?: number} responses
- No error codes — callers cannot programmatically distinguish error types
- No retry guidance — callers do not know if retrying makes sense
- No suggestions — callers get no hints on how to fix the error
Proposed Implementation
- Define
AegisError hierarchy: SessionError, PermissionError, TmuxError, ValidationError, InternalError
- Each error has:
code (string enum), retryable: boolean, suggestions: string[]
- Standardize error responses across all REST endpoints
- Add error codes to WebSocket messages
- Update API docs with error code reference
Priority
P3 — DX improvement, not blocking
Summary
Aegis returns generic error objects across all endpoints. Claude Code categorizes errors into UserError, ToolError, and SystemError with retry logic, error codes, and actionable messages.
CC Reference
src/utils/errors.ts— Error class hierarchysrc/utils/toolErrors.ts— Tool-specific error formattingsrc/services/tools/toolHooks.ts— Error handling in tool execution flowsrc/types/permissions.ts— PermissionError typesCC Architecture
UserError(user input),ToolError(tool execution),SystemError(infrastructure)code,message,retryable,suggestions[],context{}decisionReasonandblockedPathCurrent Aegis Gap
{error: string, code?: number}responsesProposed Implementation
AegisErrorhierarchy:SessionError,PermissionError,TmuxError,ValidationError,InternalErrorcode(string enum),retryable: boolean,suggestions: string[]Priority
P3 — DX improvement, not blocking