import Boom from '@hapi/boom' ; import { RequestHandlerWrapper } from './router' ; export const wrapErrors = ( handler ) => { return async ( context , request , response ) => { try { return await handler ( context , request , response ) ; } catch ( e ) { if ( Boom . isBoom ( e ) ) { return response . customError ( { body : e . output . payload , statusCode : e . output . statusCode , headers : e . output . headers as { [ key ] : string ; } , } ) ; } throw e ; } } ; } ;