/**
 * Typed errors thrown by REST handlers.
 *
 * Each error carries a stable `code` that the relay envelope dispatcher
 * (Batch 3) maps to a wire-level status. Until then, the handlers throw
 * and the relay loop just acks — Batch 3 will catch and translate.
 *
 * Why typed errors instead of returning `{ ok: false, code }` discriminated
 * unions? Two reasons:
 *  - The handlers are also called directly from unit tests; `throw` lets
 *    tests use `expect(...).rejects.toThrow(NotFoundError)` ergonomically.
 *  - The Batch 3 dispatcher needs a single `try/catch` boundary; a sum
 *    type per handler would force every handler to return its own variant.
 */
export class HandlerError extends Error {
    code;
    constructor(code, message) {
        super(message);
        this.code = code;
        this.name = "HandlerError";
    }
}
export class BadRequestError extends HandlerError {
    constructor(message) {
        super("BAD_REQUEST", message);
        this.name = "BadRequestError";
    }
}
export class NotFoundError extends HandlerError {
    constructor(message) {
        super("NOT_FOUND", message);
        this.name = "NotFoundError";
    }
}
