/**
 * Base error class for all WARP domain errors.
 *
 * Provides shared constructor logic: name (from constructor), code,
 * context, and stack trace capture. Subclasses reduce to a one-line
 * constructor calling super(message, defaultCode, options).
 */
export default class WarpError extends Error {
    code;
    context; // nosemgrep: ts-no-record-string-unknown-outside-adapters -- 0025B; nosemgrep: ts-no-unknown-outside-adapters -- 0025B
    constructor(message, defaultCode, options = {}) {
        super(message);
        const opts = options ?? {};
        this.name = this.constructor.name;
        this.code = resolveCode(opts.code, defaultCode);
        this.context = opts.context ?? {};
        Error.captureStackTrace?.(this, this.constructor);
    }
}
function resolveCode(code, defaultCode) {
    if (typeof code === 'string' && code.length > 0) {
        return code;
    }
    return defaultCode;
}
