InternalServerErrorHandler.ts 555 B

1234567891011121314
  1. import { Middleware, StatusCodes } from '../base/http';
  2. import { NextFunction, Request, Response } from 'express';
  3. import { $$ } from '../base/i18n';
  4. class InternalServerErrorHandler extends Middleware {
  5. protected order = 10000;
  6. protected route = null;
  7. protected action = (err: Error, req: Request, res: Response, next: NextFunction): any => {
  8. this.context.logError(`${err.message}: ${err.stack}`);
  9. res.status(StatusCodes.INTERNAL_SERVER_ERROR).send($$('org.crazydoctor.expressts.httpError.500'));
  10. };
  11. }
  12. export default InternalServerErrorHandler;