storemw-core-api 1.0.72 → 1.0.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,9 +5,9 @@ const zod_1 = require("zod");
|
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const errorHandler = (error, req, res, next) => {
|
|
7
7
|
if (error instanceof zod_1.ZodError) {
|
|
8
|
-
return (0, utils_1.sendError)(res, "BAD_REQUEST",
|
|
8
|
+
return (0, utils_1.sendError)(res, "BAD_REQUEST", (0, utils_1.getFormattedZodErrorsIntoString)(error), "Validation Error", "", 400);
|
|
9
9
|
}
|
|
10
|
-
return (0, utils_1.sendError)(res, "INTERNAL_SERVER_ERROR",
|
|
10
|
+
return (0, utils_1.sendError)(res, "INTERNAL_SERVER_ERROR", `Error: ${error.message || "Unknown error"}`, "Internal Server Error", "", 500);
|
|
11
11
|
};
|
|
12
12
|
exports.errorHandler = errorHandler;
|
|
13
13
|
//# sourceMappingURL=errorHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorHandler.js","sourceRoot":"","sources":["../../../src/middlewares/common/errorHandler.ts"],"names":[],"mappings":";;;AAAA,6BAA+B;AAE/B,mCAAqE;AAE9D,MAAM,YAAY,GAAG,CAAC,KAAU,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;IAExF,IAAI,KAAK,YAAY,cAAQ,EAAE,CAAC;QAC5B,OAAO,IAAA,iBAAS,EACZ,GAAG,EACH,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"errorHandler.js","sourceRoot":"","sources":["../../../src/middlewares/common/errorHandler.ts"],"names":[],"mappings":";;;AAAA,6BAA+B;AAE/B,mCAAqE;AAE9D,MAAM,YAAY,GAAG,CAAC,KAAU,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;IAExF,IAAI,KAAK,YAAY,cAAQ,EAAE,CAAC;QAC5B,OAAO,IAAA,iBAAS,EACZ,GAAG,EACH,aAAa,EACb,IAAA,uCAA+B,EAAC,KAAK,CAAC,EACtC,kBAAkB,EAClB,EAAE,EACF,GAAG,CACN,CAAC;IACN,CAAC;IAED,OAAO,IAAA,iBAAS,EACZ,GAAG,EACH,uBAAuB,EACvB,UAAU,KAAK,CAAC,OAAO,IAAI,eAAe,EAAE,EAC5C,uBAAuB,EACvB,EAAE,EACF,GAAG,CACN,CAAC;AACN,CAAC,CAAA;AArBY,QAAA,YAAY,gBAqBxB","sourcesContent":["import { ZodError } from \"zod\";\nimport { Request, Response, NextFunction } from \"express\";\nimport { sendError, getFormattedZodErrorsIntoString } from \"@/utils\";\n\nexport const errorHandler = (error: any, req: Request, res: Response, next: NextFunction) => {\n\n if (error instanceof ZodError) {\n return sendError(\n res,\n \"BAD_REQUEST\",\n getFormattedZodErrorsIntoString(error),\n \"Validation Error\",\n \"\",\n 400\n );\n }\n\n return sendError(\n res,\n \"INTERNAL_SERVER_ERROR\",\n `Error: ${error.message || \"Unknown error\"}`,\n \"Internal Server Error\",\n \"\",\n 500\n );\n}\n"]}
|