clove/system
src/lib/server/plural/errors.ts
/* src/lib/server/plural/errors.ts
* Copyright (c) 2026 Clove Nytrix Doughmination Twilight
* Licensed under the DASL-1.2 Licence.
* See LICENCE.md in the project root for full licence information.
*/
/**
* Lightweight HTTP error, thrown anywhere in the system API and translated
* into a JSON `{ detail }` response by the Hono error handler (see app.ts).
* Mirrors the old Express HttpError so ported handlers read identically.
*/
export class HttpError extends Error {
public readonly statusCode: number;
public readonly headers?: Record<string, string>;
constructor(statusCode: number, detail: string, headers?: Record<string, string>) {
super(detail);
this.name = "HttpError";
this.statusCode = statusCode;
this.headers = headers;
}
}