/** * Error creation utilities * * Helper functions for creating CoachingError instances from mapped error data. * These utilities simplify error construction when you already have structured * error information. * * @module @wavespec/kit/error */ import { CoachingError } from '@wavespec/types'; import type { MappedError } from './types.js'; /** * Create a CoachingError from mapped error data * * Takes structured error data (typically from an ErrorMapper) and creates * a CoachingError instance. This is useful when you have error data from * multiple sources or need to construct errors programmatically. * * The MappedError format matches what ErrorMapper.map() produces internally, * so this function can be used to create equivalent errors without going * through the mapper. * * @param mapped - Structured error data * @returns CoachingError instance * * @example Creating error from mapped data * ```typescript * const mappedError: MappedError = { * code: "CONNECTION_FAILED", * message: "Failed to connect to server", * hint: "The server is not reachable", * fix: "Check that the server is running", * severity: "error", * context: { port: 8080 } * }; * * const error = createCoachingError(mappedError); * throw error; * ``` * * @example Creating error with recovery strategy * ```typescript * const mappedError: MappedError = { * code: "OPERATION_TIMEOUT", * message: "Operation timed out after 30000ms", * hint: "The operation took too long", * fix: "Increase timeout in configuration", * severity: "error", * recovery: { * type: "retry", * params: { * maxAttempts: 3, * backoffMs: 1000 * } * } * }; * * throw createCoachingError(mappedError); * ``` */ export declare function createCoachingError(mapped: MappedError): CoachingError; //# sourceMappingURL=error.d.ts.map