UNPKG

907 BTypeScriptView Raw
1import { BaseController } from "./base.controller";
2import Request from "./request";
3import Response from "./response";
4/**
5 * The error controller is a custom controller that is invoked when an error
6 * occurred.
7 * It is invoked only on non-API routes (on API routes, the standard API error is used.)
8 */
9export default class ErrorController extends BaseController {
10 /**
11 * This method will be executed when a route is not found (the tipical 404
12 * error).
13 * @param req the standard lynx Request
14 */
15 onNotFound(req: Request): Promise<Response>;
16 /**
17 * This method will be executed when an error is thrown during the execution
18 * of a route.
19 * @param error The error, with an additional "statusCode" property, containing the http status code.
20 * @param req the standard lynx Request
21 */
22 onError(error: Error, req: Request): Promise<Response>;
23}