@riocrypto/common-server 1.0.2768 → 1.0.2770

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.
@@ -2,8 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.errorHandler = void 0;
4
4
  const common_1 = require("@riocrypto/common");
5
+ const isCustomErrorLike = (err) => {
6
+ if (!err || typeof err !== "object") {
7
+ return false;
8
+ }
9
+ const candidate = err;
10
+ return (typeof candidate.statusCode === "number" &&
11
+ typeof candidate.serializeErrors === "function");
12
+ };
5
13
  const errorHandler = (err, req, res, next) => {
6
- if (err instanceof common_1.CustomError) {
14
+ if (err instanceof common_1.CustomError || isCustomErrorLike(err)) {
7
15
  return res.status(err.statusCode).send({ errors: err.serializeErrors() });
8
16
  }
9
17
  console.error(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2768",
3
+ "version": "1.0.2770",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "@google-cloud/secret-manager": "^5.6.0",
25
25
  "@google-cloud/storage": "^7.19.0",
26
26
  "@hyperdx/node-opentelemetry": "^0.10.3",
27
- "@riocrypto/common": "1.0.2565",
27
+ "@riocrypto/common": "1.0.2566",
28
28
  "@slack/web-api": "^7.15.0",
29
29
  "@types/express": "^4.17.25",
30
30
  "axios": "1.13.6",