export interface ProcessErrorPayload { code: string; message: string; details?: TErrorDetails; expose?: boolean; status?: number; } /** * Custom Process Error class for structured error handling in internal processes * @template TErrorDetails - Type for additional error details (can be any type) * @extends Error - Built-in JavaScript Error class * @example * throw new ProcessError({ * code: 'VALIDATION_FAILED', * message: 'User data validation failed', * details: { field: 'email', reason: 'invalid format' }, * expose: false * status: 400 * }); */ export declare class ProcessError extends Error { /** Unique error code identifier (e.g., 'VALIDATION_ERROR', 'NOT_FOUND') */ readonly code: string; /** Additional error details with type safety via generics */ readonly details?: TErrorDetails; /** Whether to expose error details to the client (use false for sensitive errors) */ readonly expose: boolean; /** Optional HTTP status code associated with the error (e.g., 400, 500) */ readonly status?: number; /** * Creates a new ProcessError instance * @param payload - Error configuration object containing all error properties */ constructor(payload: ProcessErrorPayload); } /** * Type guard to check if an error is an instance of ProcessError * Useful for error handling logic to distinguish ProcessError from other error types * @param error - The error to check * @returns True if the error is a ProcessError instance, false otherwise * @example * try { * // some code * } catch (error) { * if (isProcessError(error)) { * console.log(error.code, error.details); * } * } */ export declare const isProcessError: (error: unknown) => error is ProcessError;