import { NextFunction , Request , Response } from "express" ; import { ResponseErrorInternal } from "italia-ts-commons/lib/responses" ; import { log } from "../logger" ; ref export function expressErrorMiddleware ( err , _ , res , __ ) { log . error ( "An exception occurred during http request: %s" , err . message ) ; if ( ! res . headersSent ) { ResponseErrorInternal ( err . message ) . apply ( res ) ; } }