UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

39 lines (38 loc) 1.24 kB
import { ErrorResult, LucidErrorData } from "../../types/errors.mjs"; import z from "zod"; //#region src/utils/errors/lucid-api-error.d.ts /** * The LucidAPIError class should be used to throw errors within the API request lifecycle. This will be caught by Hono's error handler and will return a formatted error response. If the error is a Zod error, it will be formatted into a more readable format. * @class * @extends Error * @param {LucidErrorData} error * @returns {void} * @example * throw new LucidAPIError({ * type: "basic", * name: "Fetch User Error", * message: "Error while fetching user data", * status: 500, * }); * @example * throw new LucidAPIError({ * type: "validation", * name: "Validation Error", * message: "Validation error occurred", * status: 400, * errors: { * email: { * code: "invalid_email", * message: "Invalid email address", * }, * }, * }); */ declare class LucidAPIError extends Error { error: LucidErrorData; constructor(error: LucidErrorData); static formatZodErrors(error: z.core.$ZodIssue[]): ErrorResult; } //#endregion export { LucidAPIError as default }; //# sourceMappingURL=lucid-api-error.d.mts.map