@tsed/platform-exceptions 6.107.3 → 6.108.0

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.
@@ -41,7 +41,7 @@ let ErrorFilter = class ErrorFilter {
41
41
  }, {});
42
42
  }
43
43
  };
44
- ErrorFilter = (0, tslib_1.__decorate)([
44
+ ErrorFilter = tslib_1.__decorate([
45
45
  (0, catch_1.Catch)(Error)
46
46
  ], ErrorFilter);
47
47
  exports.ErrorFilter = ErrorFilter;
@@ -16,7 +16,7 @@ let ExceptionFilter = class ExceptionFilter extends ErrorFilter_1.ErrorFilter {
16
16
  response.setHeaders(this.getHeaders(error)).contentType("application/json").status(error.status).body(err);
17
17
  }
18
18
  };
19
- ExceptionFilter = (0, tslib_1.__decorate)([
19
+ ExceptionFilter = tslib_1.__decorate([
20
20
  (0, catch_1.Catch)(exceptions_1.Exception)
21
21
  ], ExceptionFilter);
22
22
  exports.ExceptionFilter = ExceptionFilter;
@@ -10,7 +10,7 @@ let MongooseErrorFilter = class MongooseErrorFilter extends ErrorFilter_1.ErrorF
10
10
  return super.catch(new exceptions_1.BadRequest(error.message, error), ctx);
11
11
  }
12
12
  };
13
- MongooseErrorFilter = (0, tslib_1.__decorate)([
13
+ MongooseErrorFilter = tslib_1.__decorate([
14
14
  (0, catch_1.Catch)("MongooseError", "MongoError")
15
15
  ], MongooseErrorFilter);
16
16
  exports.MongooseErrorFilter = MongooseErrorFilter;
@@ -9,7 +9,7 @@ let StringErrorFilter = class StringErrorFilter {
9
9
  ctx.response.status(404).body(toHTML(error));
10
10
  }
11
11
  };
12
- StringErrorFilter = (0, tslib_1.__decorate)([
12
+ StringErrorFilter = tslib_1.__decorate([
13
13
  (0, catch_1.Catch)(String)
14
14
  ], StringErrorFilter);
15
15
  exports.StringErrorFilter = StringErrorFilter;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const Exceptions = (0, tslib_1.__importStar)(require("@tsed/exceptions"));
4
+ const Exceptions = tslib_1.__importStar(require("@tsed/exceptions"));
5
5
  const exceptions_1 = require("@tsed/exceptions");
6
6
  const schema_1 = require("@tsed/schema");
7
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ExceptionSchema.js","sourceRoot":"","sources":["../../../src/domain/ExceptionSchema.ts"],"names":[],"mappings":";;;AAAA,0EAA+C;AAC/C,iDAA2C;AAC3C,yCAAuG;AAEvG;;GAEG;AACH,MAAM,WAAW,GAAG,IAAA,eAAM,EAAC;IACzB,IAAI,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,gBAAgB,CAAC;IACvD,OAAO,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,kBAAkB,CAAC;CAC7D,CAAC;KACC,KAAK,CAAC,cAAc,CAAC;KACrB,OAAO,EAAE,CAAC;AAEb,IAAA,aAAI,EAAC,sBAAS,CAAC,CAAC,UAAU,CAAC;IACzB,IAAI,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,gBAAgB,CAAC;IACvD,OAAO,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,kBAAkB,CAAC;IAC5D,MAAM,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,kCAAkC,CAAC;IAC3E,MAAM,EAAE,IAAA,cAAK,GAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,0BAA0B,CAAC;IAC1E,KAAK,EAAE,IAAA,eAAM,GAAE,CAAC,WAAW,CAAC,4CAA4C,CAAC;CAC1E,CAAC,CAAC;AAEH,sCAAsC;AACtC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,MAAW,EAAE,EAAE;IAChD,IAAI,MAAM,KAAK,sBAAS,IAAI,MAAM,CAAC,MAAM,EAAE;QACzC,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;YACvB,MAAM,IAAI,GAAG,IAAA,0BAAiB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC9C,IAAA,aAAI,EAAC,MAAM,CAAC,CAAC,UAAU,CAAC;gBACtB,IAAI,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,gBAAgB,CAAC;gBACnF,MAAM,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,kCAAkC,CAAC;aAC1H,CAAC,CAAC;YAEH,IAAA,0BAAiB,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SAC1C;KACF;AACH,CAAC,CAAC,CAAC","sourcesContent":["import * as Exceptions from \"@tsed/exceptions\";\nimport {Exception} from \"@tsed/exceptions\";\nimport {array, defineStatusModel, from, getStatusConstant, number, object, string} from \"@tsed/schema\";\n\n/**\n * @ignore\n */\nconst ErrorSchema = object({\n name: string().required().description(\"The error name\"),\n message: string().required().description(\"An error message\")\n})\n .label(\"GenericError\")\n .unknown();\n\nfrom(Exception).properties({\n name: string().required().description(\"The error name\"),\n message: string().required().description(\"An error message\"),\n status: number().required().description(\"The status code of the exception\"),\n errors: array().items(ErrorSchema).description(\"A list of related errors\"),\n stack: string().description(\"The stack trace (only in development mode)\")\n});\n\n// Auto load models for all Exceptions\nObject.values(Exceptions).forEach((target: any) => {\n if (target !== Exception && target.STATUS) {\n if (target.STATUS > 302) {\n const name = getStatusConstant(target.STATUS);\n from(target).properties({\n name: string().required().example(name).default(name).description(\"The error name\"),\n status: number().required().example(target.STATUS).default(target.STATUS).description(\"The status code of the exception\")\n });\n\n defineStatusModel(target.STATUS, target);\n }\n }\n});\n"]}
1
+ {"version":3,"file":"ExceptionSchema.js","sourceRoot":"","sources":["../../../src/domain/ExceptionSchema.ts"],"names":[],"mappings":";;;AAAA,qEAA+C;AAC/C,iDAA2C;AAC3C,yCAAuG;AAEvG;;GAEG;AACH,MAAM,WAAW,GAAG,IAAA,eAAM,EAAC;IACzB,IAAI,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,gBAAgB,CAAC;IACvD,OAAO,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,kBAAkB,CAAC;CAC7D,CAAC;KACC,KAAK,CAAC,cAAc,CAAC;KACrB,OAAO,EAAE,CAAC;AAEb,IAAA,aAAI,EAAC,sBAAS,CAAC,CAAC,UAAU,CAAC;IACzB,IAAI,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,gBAAgB,CAAC;IACvD,OAAO,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,kBAAkB,CAAC;IAC5D,MAAM,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,kCAAkC,CAAC;IAC3E,MAAM,EAAE,IAAA,cAAK,GAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,0BAA0B,CAAC;IAC1E,KAAK,EAAE,IAAA,eAAM,GAAE,CAAC,WAAW,CAAC,4CAA4C,CAAC;CAC1E,CAAC,CAAC;AAEH,sCAAsC;AACtC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,MAAW,EAAE,EAAE;IAChD,IAAI,MAAM,KAAK,sBAAS,IAAI,MAAM,CAAC,MAAM,EAAE;QACzC,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;YACvB,MAAM,IAAI,GAAG,IAAA,0BAAiB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC9C,IAAA,aAAI,EAAC,MAAM,CAAC,CAAC,UAAU,CAAC;gBACtB,IAAI,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,gBAAgB,CAAC;gBACnF,MAAM,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,kCAAkC,CAAC;aAC1H,CAAC,CAAC;YAEH,IAAA,0BAAiB,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SAC1C;KACF;AACH,CAAC,CAAC,CAAC","sourcesContent":["import * as Exceptions from \"@tsed/exceptions\";\nimport {Exception} from \"@tsed/exceptions\";\nimport {array, defineStatusModel, from, getStatusConstant, number, object, string} from \"@tsed/schema\";\n\n/**\n * @ignore\n */\nconst ErrorSchema = object({\n name: string().required().description(\"The error name\"),\n message: string().required().description(\"An error message\")\n})\n .label(\"GenericError\")\n .unknown();\n\nfrom(Exception).properties({\n name: string().required().description(\"The error name\"),\n message: string().required().description(\"An error message\"),\n status: number().required().description(\"The status code of the exception\"),\n errors: array().items(ErrorSchema).description(\"A list of related errors\"),\n stack: string().description(\"The stack trace (only in development mode)\")\n});\n\n// Auto load models for all Exceptions\nObject.values(Exceptions).forEach((target: any) => {\n if (target !== Exception && target.STATUS) {\n if (target.STATUS > 302) {\n const name = getStatusConstant(target.STATUS);\n from(target).properties({\n name: string().required().example(name).default(name).description(\"The error name\"),\n status: number().required().example(target.STATUS).default(target.STATUS).description(\"The status code of the exception\")\n });\n\n defineStatusModel(target.STATUS, target);\n }\n }\n});\n"]}
package/lib/cjs/index.js CHANGED
@@ -4,14 +4,14 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const tslib_1 = require("tslib");
7
- (0, tslib_1.__exportStar)(require("./components/ErrorFilter"), exports);
8
- (0, tslib_1.__exportStar)(require("./components/ExceptionFilter"), exports);
9
- (0, tslib_1.__exportStar)(require("./components/MongooseErrorFilter"), exports);
10
- (0, tslib_1.__exportStar)(require("./components/StringErrorFilter"), exports);
11
- (0, tslib_1.__exportStar)(require("./decorators/catch"), exports);
12
- (0, tslib_1.__exportStar)(require("./domain/ExceptionFiltersContainer"), exports);
13
- (0, tslib_1.__exportStar)(require("./domain/ExceptionSchema"), exports);
14
- (0, tslib_1.__exportStar)(require("./errors/ResourceNotFound"), exports);
15
- (0, tslib_1.__exportStar)(require("./interfaces/ExceptionFilterMethods"), exports);
16
- (0, tslib_1.__exportStar)(require("./services/PlatformExceptions"), exports);
7
+ tslib_1.__exportStar(require("./components/ErrorFilter"), exports);
8
+ tslib_1.__exportStar(require("./components/ExceptionFilter"), exports);
9
+ tslib_1.__exportStar(require("./components/MongooseErrorFilter"), exports);
10
+ tslib_1.__exportStar(require("./components/StringErrorFilter"), exports);
11
+ tslib_1.__exportStar(require("./decorators/catch"), exports);
12
+ tslib_1.__exportStar(require("./domain/ExceptionFiltersContainer"), exports);
13
+ tslib_1.__exportStar(require("./domain/ExceptionSchema"), exports);
14
+ tslib_1.__exportStar(require("./errors/ResourceNotFound"), exports);
15
+ tslib_1.__exportStar(require("./interfaces/ExceptionFilterMethods"), exports);
16
+ tslib_1.__exportStar(require("./services/PlatformExceptions"), exports);
17
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,wEAAyC;AACzC,4EAA6C;AAC7C,gFAAiD;AACjD,8EAA+C;AAC/C,kEAAmC;AACnC,kFAAmD;AACnD,wEAAyC;AACzC,yEAA0C;AAC1C,mFAAoD;AACpD,6EAA8C","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./components/ErrorFilter\";\nexport * from \"./components/ExceptionFilter\";\nexport * from \"./components/MongooseErrorFilter\";\nexport * from \"./components/StringErrorFilter\";\nexport * from \"./decorators/catch\";\nexport * from \"./domain/ExceptionFiltersContainer\";\nexport * from \"./domain/ExceptionSchema\";\nexport * from \"./errors/ResourceNotFound\";\nexport * from \"./interfaces/ExceptionFilterMethods\";\nexport * from \"./services/PlatformExceptions\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,mEAAyC;AACzC,uEAA6C;AAC7C,2EAAiD;AACjD,yEAA+C;AAC/C,6DAAmC;AACnC,6EAAmD;AACnD,mEAAyC;AACzC,oEAA0C;AAC1C,8EAAoD;AACpD,wEAA8C","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./components/ErrorFilter\";\nexport * from \"./components/ExceptionFilter\";\nexport * from \"./components/MongooseErrorFilter\";\nexport * from \"./components/StringErrorFilter\";\nexport * from \"./decorators/catch\";\nexport * from \"./domain/ExceptionFiltersContainer\";\nexport * from \"./domain/ExceptionSchema\";\nexport * from \"./errors/ResourceNotFound\";\nexport * from \"./interfaces/ExceptionFilterMethods\";\nexport * from \"./services/PlatformExceptions\";\n"]}
@@ -42,11 +42,11 @@ let PlatformExceptions = class PlatformExceptions {
42
42
  return this.catch(new ResourceNotFound_1.ResourceNotFound(ctx.request.url), ctx);
43
43
  }
44
44
  };
45
- (0, tslib_1.__decorate)([
45
+ tslib_1.__decorate([
46
46
  (0, di_1.Inject)(),
47
- (0, tslib_1.__metadata)("design:type", di_1.InjectorService)
47
+ tslib_1.__metadata("design:type", di_1.InjectorService)
48
48
  ], PlatformExceptions.prototype, "injector", void 0);
49
- PlatformExceptions = (0, tslib_1.__decorate)([
49
+ PlatformExceptions = tslib_1.__decorate([
50
50
  (0, di_1.Injectable)({
51
51
  imports: [ErrorFilter_1.ErrorFilter, ExceptionFilter_1.ExceptionFilter, MongooseErrorFilter_1.MongooseErrorFilter, StringErrorFilter_1.StringErrorFilter]
52
52
  })
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformExceptions.js","sourceRoot":"","sources":["../../../src/services/PlatformExceptions.ts"],"names":[],"mappings":";;;;AAAA,qCAAwD;AACxD,iCAA0E;AAC1E,2DAAsD;AACtD,mEAA8D;AAC9D,2EAAsE;AACtE,uEAAkE;AAClE,mFAAkG;AAClG,iEAA4D;AAG5D;;;;GAIG;AAIH,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAA/B;QACE,UAAK,GAAoD,IAAI,GAAG,EAAE,CAAC;IAiCrE,CAAC;IA5BC,OAAO;QACL,qDAAyB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAChD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAc,EAAE,GAAgB;QACpC,MAAM,IAAI,GAAG,IAAA,aAAM,EAAC,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC,CAAC;QAEpC,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAChC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SAChD;QAED,MAAM,MAAM,GAAG,IAAA,kBAAW,EAAC,KAAK,CAAC;aAC9B,OAAO,EAAE;aACT,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QAE5C,IAAI,MAAM,EAAE;YACV,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SAClD;QAED,UAAU;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC;IAED,gBAAgB,CAAC,GAAgB;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,mCAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;CACF,CAAA;AA9BC;IADC,IAAA,WAAM,GAAE;2CACC,oBAAe;oDAAC;AAJf,kBAAkB;IAH9B,IAAA,eAAU,EAAC;QACV,OAAO,EAAE,CAAC,yBAAW,EAAE,iCAAe,EAAE,yCAAmB,EAAE,qCAAiB,CAAC;KAChF,CAAC;GACW,kBAAkB,CAkC9B;AAlCY,gDAAkB","sourcesContent":["import {ancestorsOf, classOf, nameOf} from \"@tsed/core\";\nimport {BaseContext, Inject, Injectable, InjectorService} from \"@tsed/di\";\nimport {ErrorFilter} from \"../components/ErrorFilter\";\nimport {ExceptionFilter} from \"../components/ExceptionFilter\";\nimport {MongooseErrorFilter} from \"../components/MongooseErrorFilter\";\nimport {StringErrorFilter} from \"../components/StringErrorFilter\";\nimport {ExceptionFilterKey, ExceptionFiltersContainer} from \"../domain/ExceptionFiltersContainer\";\nimport {ResourceNotFound} from \"../errors/ResourceNotFound\";\nimport {ExceptionFilterMethods} from \"../interfaces/ExceptionFilterMethods\";\n\n/**\n * Catch all errors and return the json error with the right status code when it's possible.\n *\n * @platform\n */\n@Injectable({\n imports: [ErrorFilter, ExceptionFilter, MongooseErrorFilter, StringErrorFilter]\n})\nexport class PlatformExceptions {\n types: Map<ExceptionFilterKey, ExceptionFilterMethods> = new Map();\n\n @Inject()\n injector: InjectorService;\n\n $onInit() {\n ExceptionFiltersContainer.forEach((token, type) => {\n this.types.set(type, this.injector.get(token)!);\n });\n }\n\n catch(error: unknown, ctx: BaseContext) {\n const name = nameOf(classOf(error));\n\n if (name && this.types.has(name)) {\n return this.types.get(name)!.catch(error, ctx);\n }\n\n const target = ancestorsOf(error)\n .reverse()\n .find((target) => this.types.has(target));\n\n if (target) {\n return this.types.get(target)!.catch(error, ctx);\n }\n\n // default\n return this.types.get(Error)!.catch(error, ctx);\n }\n\n resourceNotFound(ctx: BaseContext) {\n return this.catch(new ResourceNotFound(ctx.request.url), ctx);\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformExceptions.js","sourceRoot":"","sources":["../../../src/services/PlatformExceptions.ts"],"names":[],"mappings":";;;;AAAA,qCAAwD;AACxD,iCAA0E;AAC1E,2DAAsD;AACtD,mEAA8D;AAC9D,2EAAsE;AACtE,uEAAkE;AAClE,mFAAkG;AAClG,iEAA4D;AAG5D;;;;GAIG;AAIH,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAA/B;QACE,UAAK,GAAoD,IAAI,GAAG,EAAE,CAAC;IAiCrE,CAAC;IA5BC,OAAO;QACL,qDAAyB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAChD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAc,EAAE,GAAgB;QACpC,MAAM,IAAI,GAAG,IAAA,aAAM,EAAC,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC,CAAC;QAEpC,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAChC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SAChD;QAED,MAAM,MAAM,GAAG,IAAA,kBAAW,EAAC,KAAK,CAAC;aAC9B,OAAO,EAAE;aACT,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QAE5C,IAAI,MAAM,EAAE;YACV,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SAClD;QAED,UAAU;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC;IAED,gBAAgB,CAAC,GAAgB;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,mCAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;CACF,CAAA;AA9BC;IADC,IAAA,WAAM,GAAE;sCACC,oBAAe;oDAAC;AAJf,kBAAkB;IAH9B,IAAA,eAAU,EAAC;QACV,OAAO,EAAE,CAAC,yBAAW,EAAE,iCAAe,EAAE,yCAAmB,EAAE,qCAAiB,CAAC;KAChF,CAAC;GACW,kBAAkB,CAkC9B;AAlCY,gDAAkB","sourcesContent":["import {ancestorsOf, classOf, nameOf} from \"@tsed/core\";\nimport {BaseContext, Inject, Injectable, InjectorService} from \"@tsed/di\";\nimport {ErrorFilter} from \"../components/ErrorFilter\";\nimport {ExceptionFilter} from \"../components/ExceptionFilter\";\nimport {MongooseErrorFilter} from \"../components/MongooseErrorFilter\";\nimport {StringErrorFilter} from \"../components/StringErrorFilter\";\nimport {ExceptionFilterKey, ExceptionFiltersContainer} from \"../domain/ExceptionFiltersContainer\";\nimport {ResourceNotFound} from \"../errors/ResourceNotFound\";\nimport {ExceptionFilterMethods} from \"../interfaces/ExceptionFilterMethods\";\n\n/**\n * Catch all errors and return the json error with the right status code when it's possible.\n *\n * @platform\n */\n@Injectable({\n imports: [ErrorFilter, ExceptionFilter, MongooseErrorFilter, StringErrorFilter]\n})\nexport class PlatformExceptions {\n types: Map<ExceptionFilterKey, ExceptionFilterMethods> = new Map();\n\n @Inject()\n injector: InjectorService;\n\n $onInit() {\n ExceptionFiltersContainer.forEach((token, type) => {\n this.types.set(type, this.injector.get(token)!);\n });\n }\n\n catch(error: unknown, ctx: BaseContext) {\n const name = nameOf(classOf(error));\n\n if (name && this.types.has(name)) {\n return this.types.get(name)!.catch(error, ctx);\n }\n\n const target = ancestorsOf(error)\n .reverse()\n .find((target) => this.types.has(target));\n\n if (target) {\n return this.types.get(target)!.catch(error, ctx);\n }\n\n // default\n return this.types.get(Error)!.catch(error, ctx);\n }\n\n resourceNotFound(ctx: BaseContext) {\n return this.catch(new ResourceNotFound(ctx.request.url), ctx);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/platform-exceptions",
3
- "version": "6.107.3",
3
+ "version": "6.108.0",
4
4
  "description": "Platform exceptions module for Ts.ED Framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -20,19 +20,33 @@
20
20
  "barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\""
21
21
  },
22
22
  "dependencies": {
23
- "tslib": "2.2.0"
23
+ "tslib": "2.3.1"
24
24
  },
25
25
  "devDependencies": {
26
- "@tsed/core": "6.107.3",
27
- "@tsed/di": "6.107.3",
28
- "@tsed/exceptions": "6.107.3",
29
- "@tsed/schema": "6.107.3"
26
+ "@tsed/core": "6.108.0",
27
+ "@tsed/di": "6.108.0",
28
+ "@tsed/exceptions": "6.108.0",
29
+ "@tsed/schema": "6.108.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "@tsed/core": "^6.107.3",
33
- "@tsed/di": "^6.107.3",
34
- "@tsed/exceptions": "^6.107.3",
35
- "@tsed/schema": "^6.107.3"
32
+ "@tsed/core": "^6.108.0",
33
+ "@tsed/di": "^6.108.0",
34
+ "@tsed/exceptions": "^6.108.0",
35
+ "@tsed/schema": "^6.108.0"
36
+ },
37
+ "peerDependenciesMeta": {
38
+ "@tsed/core": {
39
+ "optional": false
40
+ },
41
+ "@tsed/di": {
42
+ "optional": false
43
+ },
44
+ "@tsed/exceptions": {
45
+ "optional": false
46
+ },
47
+ "@tsed/schema": {
48
+ "optional": false
49
+ }
36
50
  },
37
51
  "repository": "https://github.com/tsedio/tsed",
38
52
  "bugs": {