import * as _homer0_jimple from '@homer0/jimple'; import { J as Jimpex } from '../../index-DAUqbQ6h.js'; import { Statuses } from '../../utils/fns/statuses.js'; import '../../types/express.js'; import 'express'; import '../../types/http.js'; import 'https'; import 'http'; import 'spdy'; import 'node-fetch'; import '../../types/utils.js'; import '@homer0/path-utils'; import '@homer0/simple-logger'; import '@homer0/simple-config'; import '@homer0/events-hub'; import 'statuses'; /** * A dictionary with some context information that can be provided to {@link AppError}. * * @group Services/AppError */ type AppErrorContext = { /** * Extra information that the error handler can pick and include the response. */ response?: unknown; /** * A status code or name for the error handler to set in the response. */ status?: string | number; } & Record; /** * A simple subclass of `Error` but with support for context information. * * @group Services * @group Services/AppError */ declare class AppError extends Error { /** * The date of when the error was generated. */ readonly _date: Date; /** * The context information that can be provided to the error, and picked by the error * handler. */ readonly _context: AppErrorContext; /** * The service that generates HTTP status codes. */ protected _statuses: Statuses; /** * @param message The message of the error. * @param context The context information, for the error handler. * @param statuses A reference to the service that generates HTTP status codes. This * is in case the implementation wants to use a special version from * the container; otherwise, it will use the `statuses` library * directly. */ constructor(message: string, context?: AppErrorContext, statuses?: Statuses); /** * Gets an object that can be included in a response from the application. This method * is a helper for the `response` getter, as it allows for the assertion of the response * type. * * @template T The type of the response. */ getResponse(): T; /** * Information about the error that can be included in a response. This is set using the * `response` key in the `context` option. */ get response(): unknown; /** * An HTTP status code related to the error. This is set using the `status` key on the * `context`. */ get status(): number | undefined; /** * Context information related to the error. */ get context(): unknown; /** * The date of when the error was generated. */ get date(): Date; /** * Utility method that formats the context before saving it in the instance: * - If the context includes a `status` as a `string`, it will try to replace it with * its actual status code from the `statuses `service. * * @param context The original context sent to the constructor. */ protected _parseContext(context: AppErrorContext): AppErrorContext; } /** * Shorthand for `new AppError()`. * * @param args The same parameters as the {@link AppError} constructor. * @returns A new instance of {@link AppError}. * @group Services * @group Services/AppError */ declare const createAppError: (...args: ConstructorParameters) => AppError; /** * The type of the function that generates a new instance of {@link AppError}. * This is exported to make it easy to type the dependency injection. * * @group Services/AppError */ type CreateAppErrorFn = typeof createAppError; /** * THe type of the {@link AppError} class. * This is exported to make it easy to type the dependency injection. * * @group Services/AppError */ type AppErrorClass = typeof AppError; /** * A service provider that will register both, {@link AppError} and * {@link createAppError}, on the container. `AppError` will be the key for class, and * `appError` will be for the generator function. * * @example * * // Register it on the container * container.register(appErrorProvider); * // Getting access to the class. * const AppError = container.get('AppError'); * // Getting access to the function. * const appError = container.get('appError'); * * @group Providers * @group Services/AppError */ declare const appErrorProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn>; export { AppError, type AppErrorClass, type AppErrorContext, type CreateAppErrorFn, appErrorProvider, createAppError };