Skip to content

Commit

Permalink
fix(platform-exceptions): support fastify error convention
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Feb 29, 2024
1 parent 67ade57 commit f18184c
Show file tree
Hide file tree
Showing 66 changed files with 250 additions and 248 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,4 @@
]
},
"packageManager": "yarn@4.1.0"
}
}
5 changes: 2 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@
"barrelsby": "^2.8.1",
"eslint": "^8.12.0",
"jest": "^29.2.0"
},
"peerDependencies": {}
}
}
}
2 changes: 1 addition & 1 deletion packages/di/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
"optional": false
}
}
}
}
5 changes: 2 additions & 3 deletions packages/engines/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,5 @@
"decorators",
"engines",
"view"
],
"peerDependencies": {}
}
]
}
2 changes: 1 addition & 1 deletion packages/graphql/apollo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
"apollo-server-core": ">=3.0.0",
"graphql": ">15.0.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/graphql/graphql-ws/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
"@tsed/logger": ">=6.2.2",
"graphql-ws": ">=5.14.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/graphql/typegraphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
"graphql": ">=15.0.0",
"type-graphql": ">=1.0.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/orm/adapters-redis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
"ioredis-mock": ">=8.2.2",
"uuid": "8.3.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/orm/adapters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/orm/ioredis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
"ioredis": ">=5.2.3",
"ioredis-mock": ">=8.2.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/orm/mikro-orm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
"@tsed/di": "7.61.2",
"@tsed/logger": ">=6.2.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/orm/mongoose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
"@tsed/schema": "7.61.2",
"mongoose": ">=6.0.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/orm/objection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/orm/prisma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@
"tsed",
"prisma"
]
}
}
2 changes: 1 addition & 1 deletion packages/orm/testing-mongoose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
"@tsed/mongoose": "7.61.2",
"mongoose": ">=6.0.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/orm/typeorm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
"publishConfig": {
"distTag": "deprecated"
}
}
}
5 changes: 2 additions & 3 deletions packages/perf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@
"@tsed/typescript": "workspace:*",
"eslint": "^8.12.0",
"jest": "^29.2.0"
},
"peerDependencies": {}
}
}
}
2 changes: 1 addition & 1 deletion packages/platform/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/platform/platform-cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/platform/platform-exceptions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
"optional": false
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,30 @@ describe("ErrorFilter", () => {
const errorFilterInstance = new ErrorFilter();
expect(errorFilterInstance.mapError(error).errors).toEqual([error.errors]);
});
it("should map error if has error.code", () => {
const error = {
errors: {
"ingredients.0.product": {
stringValue:
"\"{\n id: '5e9a0c1d5575346932e090f0',\n label: 'Artichauts',\n shelf: 'produce',\n minimumQuantity: 0,\n users: []\n}\"",
kind: "ObjectId",
value: {
id: "5e9a0c1d5575346932e090f0",
label: "Artichauts",
shelf: "produce",
minimumQuantity: 0,
users: []
},
path: "product",
reason: {}
}
},
_message: "Recipe validation failed",
code: "ValidationError",
message:
"Recipe validation failed: ingredients.0.product: Cast to ObjectId failed for value \"{\n id: '5e9a0c1d5575346932e090f0',\n label: 'Artichauts',\n shelf: 'produce',\n minimumQuantity: 0,\n users: []\n}\" at path \"product\""
};
const errorFilterInstance = new ErrorFilter();
expect(errorFilterInstance.mapError(error).errors).toEqual([error.errors]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export class ErrorFilter implements ExceptionFilterMethods {

mapError(error: any, env?: Env) {
return {
name: error.origin?.name || error.name,
name: error.origin?.name || error.name || error.code,
message: error.message,
status: error.status || 500,
status: error.status || error.statusCode || 500,
errors: this.getErrors(error),
stack: env === Env.DEV ? error.stack : undefined
};
Expand Down
2 changes: 1 addition & 1 deletion packages/platform/platform-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/platform/platform-koa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/platform/platform-log-middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/platform/platform-middlewares/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
"optional": true
}
}
}
}
2 changes: 1 addition & 1 deletion packages/platform/platform-params/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/platform/platform-response-filter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/platform/platform-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/platform/platform-serverless-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/platform/platform-serverless-testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@
"@tsed/openspec": "7.61.2",
"@tsed/schema": "7.61.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/platform/platform-serverless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@
"optional": true
}
}
}
}
5 changes: 2 additions & 3 deletions packages/platform/platform-test-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@
"barrelsby": "^2.8.1",
"eslint": "^8.12.0",
"jest": "^29.2.0"
},
"peerDependencies": {}
}
}
}
2 changes: 1 addition & 1 deletion packages/platform/platform-views/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@
"optional": false
}
}
}
}
5 changes: 2 additions & 3 deletions packages/security/jwks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@
"barrelsby": "^2.8.1",
"eslint": "^8.12.0",
"jest": "^29.2.0"
},
"peerDependencies": {}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/security/oidc-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/security/passport/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/specs/ajv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/specs/exceptions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
"peerDependencies": {
"@tsed/core": "7.61.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/specs/json-mapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@
"optional": false
}
}
}
}
6 changes: 2 additions & 4 deletions packages/specs/openspec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,5 @@
"barrelsby": "^2.8.1",
"eslint": "^8.12.0",
"jest": "^29.2.0"
},
"dependencies": {},
"peerDependencies": {}
}
}
}
2 changes: 1 addition & 1 deletion packages/specs/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/specs/swagger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/third-parties/agenda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
"peerDependencies": {
"agenda": ">=4"
}
}
}
2 changes: 1 addition & 1 deletion packages/third-parties/bullmq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
"peerDependencies": {
"bullmq": "^4.12.3 || ^5.1.1"
}
}
}
2 changes: 1 addition & 1 deletion packages/third-parties/components-scan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
"optional": false
}
}
}
}
2 changes: 1 addition & 1 deletion packages/third-parties/event-emitter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
"peerDependencies": {
"eventemitter2": "^6.4.4"
}
}
}
2 changes: 1 addition & 1 deletion packages/third-parties/formio-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
"eslint": "^8.12.0",
"jest": "^29.2.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/third-parties/formio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
"optional": false
}
}
}
}

0 comments on commit f18184c

Please sign in to comment.