|
|
@@ -3,20 +3,25 @@ import { HTTPStatus } from 'deps';
|
|
|
import { logger } from 'infra/logger.ts';
|
|
|
import Controller from 'if/controllers/controller.class.ts';
|
|
|
|
|
|
+const NotFoundController = new Controller({
|
|
|
+ '*_*': (req: Request) => {
|
|
|
+ return Controller.response(req, 'not found', {
|
|
|
+ status: HTTPStatus.NotFound,
|
|
|
+ });
|
|
|
+ },
|
|
|
+});
|
|
|
+
|
|
|
+const InternalServerErrorController = new Controller({
|
|
|
+ '*_*': (req: Request, error?: string) => {
|
|
|
+ logger.error(error);
|
|
|
+ return Controller.response(req, 'internal server error', {
|
|
|
+ status: HTTPStatus.InternalServerError,
|
|
|
+ });
|
|
|
+ },
|
|
|
+});
|
|
|
+
|
|
|
export const ControllerErrors = {
|
|
|
- NotFound: new Controller({
|
|
|
- '*_*': (req: Request) => {
|
|
|
- return Controller.response(req, 'not found', {
|
|
|
- status: HTTPStatus.NotFound,
|
|
|
- });
|
|
|
- },
|
|
|
- }),
|
|
|
- InternalServerError: new Controller({
|
|
|
- '*_*': (req: Request, error?: string) => {
|
|
|
- logger.error(error);
|
|
|
- return Controller.response(req, 'internal server error', {
|
|
|
- status: HTTPStatus.InternalServerError,
|
|
|
- });
|
|
|
- },
|
|
|
- }),
|
|
|
+ NotFound: (req: Request) => NotFoundController.handlers['*_*'](req),
|
|
|
+ InternalServerError: (req: Request, error?: string) =>
|
|
|
+ InternalServerErrorController.handlers['*_*'](req, error),
|
|
|
};
|