UNPKG

@decaf-ts/core

Version:

Core persistence module for the decaf framework

57 lines (56 loc) 2.03 kB
import { BadRequestError, InternalError } from "@decaf-ts/db-decorators"; /** * @description Error thrown when a user is not authorized to perform an action * @summary This error is thrown when a user attempts to access a resource or perform an action without proper authentication * @param {string|Error} msg - The error message or Error object * @class AuthorizationError * @category Errors * @example * ```typescript * // Example of throwing an AuthorizationError * if (!user.isAuthenticated()) { * throw new AuthorizationError('User not authenticated'); * } * ``` */ export declare class AuthorizationError extends BadRequestError { constructor(msg: string | Error, name?: string, code?: number); } /** * @description Error thrown when a user is forbidden from accessing a resource * @summary This error is thrown when an authenticated user attempts to access a resource or perform an action they don't have permission for * @param {string|Error} msg - The error message or Error object * @return {void} * @class ForbiddenError * @category Errors * @example * ```typescript * // Example of throwing a ForbiddenError * if (!user.hasPermission('admin')) { * throw new ForbiddenError('User does not have admin permissions'); * } * ``` */ export declare class ForbiddenError extends AuthorizationError { constructor(msg: string | Error, name?: string); } /** * @description Error thrown when a connection to a service fails * @summary This error is thrown when the application fails to establish a connection to a required service or resource * @param {string|Error} msg - The error message or Error object * @return {void} * @class ConnectionError * @category Errors * @example * ```typescript * // Example of throwing a ConnectionError * try { * await database.connect(); * } catch (error) { * throw new ConnectionError('Failed to connect to database'); * } * ``` */ export declare class ConnectionError extends InternalError { constructor(msg: string | Error); }