UNPKG

@codervisor/devlog-core

Version:

Core devlog management functionality

90 lines 3.19 kB
/** * Standardized error handling for the devlog system * Provides consistent error types and handling patterns */ /** * Base error class for all devlog-related errors */ export declare class DevlogError extends Error { readonly timestamp: string; readonly context?: Record<string, unknown>; constructor(message: string, context?: Record<string, unknown>); /** * Serialize error for logging */ toLogObject(): Record<string, unknown>; } /** * Configuration-related errors */ export declare class DevlogConfigurationError extends DevlogError { constructor(message: string, context?: Record<string, unknown>); } /** * Storage-related errors */ export declare class DevlogStorageError extends DevlogError { readonly operation: string; constructor(operation: string, message: string, context?: Record<string, unknown>); } /** * Validation errors for input data */ export declare class DevlogValidationError extends DevlogError { readonly field?: string; constructor(message: string, field?: string, context?: Record<string, unknown>); } /** * Errors related to devlog entries not being found */ export declare class DevlogNotFoundError extends DevlogError { readonly id: string | number; constructor(id: string | number, context?: Record<string, unknown>); } /** * API-related errors (GitHub, Jira, etc.) */ export declare class DevlogAPIError extends DevlogError { readonly service: string; readonly statusCode?: number; readonly responseBody?: unknown; constructor(service: string, message: string, statusCode?: number, responseBody?: unknown, context?: Record<string, unknown>); } /** * Network/connectivity errors */ export declare class DevlogNetworkError extends DevlogError { readonly originalError?: Error; constructor(message: string, originalError?: Error, context?: Record<string, unknown>); } /** * Simple logger interface for standardized error logging */ export interface Logger { error(message: string, context?: Record<string, unknown>): void; warn(message: string, context?: Record<string, unknown>): void; info(message: string, context?: Record<string, unknown>): void; debug(message: string, context?: Record<string, unknown>): void; } /** * Default console logger implementation */ export declare class ConsoleLogger implements Logger { error(message: string, context?: Record<string, unknown>): void; warn(message: string, context?: Record<string, unknown>): void; info(message: string, context?: Record<string, unknown>): void; debug(message: string, context?: Record<string, unknown>): void; } /** * Global logger instance */ export declare const logger: Logger; /** * Helper function to handle async operations with proper error logging */ export declare function handleAsyncOperation<T>(operation: () => Promise<T>, operationName: string, context?: Record<string, unknown>): Promise<T>; /** * Helper function to wrap operations that might throw and convert to DevlogError */ export declare function wrapError<T>(operation: () => T, errorMessage: string, context?: Record<string, unknown>): T; //# sourceMappingURL=errors.d.ts.map