'use strict' ; import { Router , ErrorRequestHandler , Request , Response , NextFunction } from 'express' ; import { Logger } from '@Tools/Logging' ; import createError , { HttpError } from 'http-errors' ; export const name = "ERROR" ; export const router = Router ( ) ; router . use ( ( req , res , next ) => { Logger . debug ( 'procCreateError: no response so returning 404' ) ; next ( createError ( 404 ) ) ; } ) ; router . use ( ( err , req , res , next ) => { Logger . debug ( 'procFinalError: generating final error' ) ; res . locals . message = err . message ; res . locals . error = req . app . get ( 'env' ) === 'development' ? err : { } ; res . status ( err . status || 500 ) ; res . end ( ) ; } ) ;