//=> src/app/middlewares/globalErrorhandeler.tsexportconstglobalErrorHandeler:ErrorRequestHandler=(err,req,res,next,)=>{letstatusCode=err.statusCode||500;letmessage=err.message||'Something went wrong';leterrorSources:TErrorSources=[{path:'',message:'something went wrong',},];if (errinstanceofZodError){constsimpliedError=handleZodError(err);statusCode=simpliedError?.statusCode;message=simpliedError?.message;errorSources=simpliedError?.errorSources;}returnres.status(statusCode).json({success:false,message,errorSources,stack:config.NODE_ENV==='development'?err?.stack:null,});};
Top comments (0)