mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
25 lines
754 B
TypeScript
25 lines
754 B
TypeScript
|
|
import type { ContentfulStatusCode } from "hono/utils/http-status";
|
||
|
|
import type { JSONObject } from "hono/utils/types";
|
||
|
|
|
||
|
|
/**
|
||
|
|
* API Error
|
||
|
|
*
|
||
|
|
* Custom error class used to throw errors in the API. Includes a status code, a message and an optional description.
|
||
|
|
* @extends Error
|
||
|
|
*/
|
||
|
|
export class ApiError extends Error {
|
||
|
|
/**
|
||
|
|
* @param {StatusCode} status - The status code of the error
|
||
|
|
* @param {string} message - The message of the error
|
||
|
|
* @param {string | JSONObject} [details] - The description of the error
|
||
|
|
*/
|
||
|
|
public constructor(
|
||
|
|
public status: ContentfulStatusCode,
|
||
|
|
public message: string,
|
||
|
|
public details?: string | JSONObject,
|
||
|
|
) {
|
||
|
|
super(message);
|
||
|
|
this.name = "ApiError";
|
||
|
|
}
|
||
|
|
}
|