export class ApiError extends Error {
    statusCode;
    code;
    details;
    constructor(code, message, statusCode = 400, details) {
        super(message);
        this.code = code;
        this.statusCode = statusCode;
        this.details = details;
        Error.captureStackTrace(this, this.constructor);
    }
}
export function errorEnvelope(error, requestId) {
    return {
        code: error.code,
        message: error.message,
        details: error.details,
        request_id: requestId,
        timestamp: new Date().toISOString()
    };
}
