Base error class for all Praman errors.
Extends Error with structured diagnostic fields:
Error
code
ErrorCode
attempted
retryable
severity
details
suggestions
timestamp
const error = new PramanError({ code: 'ERR_CONFIG_INVALID', message: 'Invalid config', attempted: 'Load config', retryable: false,});logger.error(error.toUserMessage()); Copy
const error = new PramanError({ code: 'ERR_CONFIG_INVALID', message: 'Invalid config', attempted: 'Load config', retryable: false,});logger.error(error.toUserMessage());
Readonly
Returns structured context for AI agents to reason about the error.
AI-friendly context object.
Same as toJSON() but omits stack and name — AI agents don't need stack traces, and the error type is conveyed by code.
toJSON()
stack
name
const context = error.toAIContext();// Send to LLM for self-healing analysis Copy
const context = error.toAIContext();// Send to LLM for self-healing analysis
Serializes the error to a plain JSON-safe object.
Structured representation with all diagnostic fields.
const json = error.toJSON();logger.debug(JSON.stringify(json, null, 2)); Copy
const json = error.toJSON();logger.debug(JSON.stringify(json, null, 2));
Formats the error for human-readable console output.
Multi-line formatted string with all diagnostic sections.
console.error(error.toUserMessage()); Copy
console.error(error.toUserMessage());
Base error class for all Praman errors.
Remarks
Extends
Errorwith structured diagnostic fields:code— machine-readable error code fromErrorCodeattempted— human description of the operation that failedretryable— whether the caller can retry the operationseverity— 'error', 'warning', or 'info'details— structured key-value contextsuggestions— recovery hints for humans and AI agentstimestamp— ISO 8601 creation timeExample