@tsed/platform-exceptions 8.34.0 → 8.36.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.
@@ -1,6 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
- import { Env } from "@tsed/core";
3
2
  import { Catch } from "../decorators/catch.js";
3
+ import { Env } from "@tsed/core";
4
4
  let ErrorFilter = class ErrorFilter {
5
5
  catch(error, ctx) {
6
6
  const { response, logger, env } = ctx;
@@ -1,7 +1,7 @@
1
1
  import { __decorate } from "tslib";
2
- import { Exception } from "@tsed/exceptions";
3
2
  import { Catch } from "../decorators/catch.js";
4
3
  import { ErrorFilter } from "./ErrorFilter.js";
4
+ import { Exception } from "@tsed/exceptions";
5
5
  let ExceptionFilter = class ExceptionFilter extends ErrorFilter {
6
6
  catch(error, ctx) {
7
7
  const { response, env } = ctx;
@@ -1,30 +1,31 @@
1
1
  import * as Exceptions from "@tsed/exceptions";
2
+ import { defineStatusModel, getStatusConstant, s } from "@tsed/schema";
2
3
  import { Exception } from "@tsed/exceptions";
3
- import { array, defineStatusModel, from, getStatusConstant, number, object, string } from "@tsed/schema";
4
4
  /**
5
5
  * @ignore
6
6
  */
7
- const ErrorSchema = object({
8
- name: string().required().description("The error name"),
9
- message: string().required().description("An error message")
7
+ const ErrorSchema = s
8
+ .object({
9
+ name: s.string().required().description("The error name"),
10
+ message: s.string().required().description("An error message")
10
11
  })
11
12
  .label("GenericError")
12
13
  .unknown();
13
- from(Exception).properties({
14
- name: string().required().description("The error name"),
15
- message: string().required().description("An error message"),
16
- status: number().required().description("The status code of the exception"),
17
- errors: array().items(ErrorSchema).description("A list of related errors"),
18
- stack: string().description("The stack trace (only in development mode)")
14
+ s.get(Exception).properties({
15
+ name: s.string().required().description("The error name"),
16
+ message: s.string().required().description("An error message"),
17
+ status: s.number().required().description("The status code of the exception"),
18
+ errors: s.array().items(ErrorSchema).description("A list of related errors"),
19
+ stack: s.string().description("The stack trace (only in development mode)")
19
20
  });
20
21
  // Auto load models for all Exceptions
21
22
  Object.values(Exceptions).forEach((target) => {
22
23
  if (target !== Exception && target.STATUS) {
23
24
  if (target.STATUS > 302) {
24
25
  const name = getStatusConstant(target.STATUS);
25
- from(target).properties({
26
- name: string().required().example(name).default(name).description("The error name"),
27
- status: number().required().example(target.STATUS).default(target.STATUS).description("The status code of the exception")
26
+ s.get(target).properties({
27
+ name: s.string().required().example(name).default(name).description("The error name"),
28
+ status: s.number().required().example(target.STATUS).default(target.STATUS).description("The status code of the exception")
28
29
  });
29
30
  defineStatusModel(target.STATUS, target);
30
31
  }
@@ -1,11 +1,11 @@
1
- import { ancestorsOf, classOf, nameOf } from "@tsed/core";
2
1
  import { inject, injectable } from "@tsed/di";
2
+ import { ExceptionFiltersContainer } from "../domain/ExceptionFiltersContainer.js";
3
+ import { ancestorsOf, classOf, nameOf } from "@tsed/core";
3
4
  import { ErrorFilter } from "../components/ErrorFilter.js";
4
5
  import { ExceptionFilter } from "../components/ExceptionFilter.js";
5
6
  import { MongooseErrorFilter } from "../components/MongooseErrorFilter.js";
6
- import { StringErrorFilter } from "../components/StringErrorFilter.js";
7
- import { ExceptionFiltersContainer } from "../domain/ExceptionFiltersContainer.js";
8
7
  import { ResourceNotFound } from "../errors/ResourceNotFound.js";
8
+ import { StringErrorFilter } from "../components/StringErrorFilter.js";
9
9
  /**
10
10
  * Catch all errors and return the json error with the right status code when it's possible.
11
11
  *
@@ -1,5 +1,5 @@
1
- import { Env } from "@tsed/core";
2
1
  import { BaseContext } from "@tsed/di";
2
+ import { Env } from "@tsed/core";
3
3
  import type { ExceptionFilterMethods } from "../interfaces/ExceptionFilterMethods.js";
4
4
  export declare class ErrorFilter implements ExceptionFilterMethods {
5
5
  catch(error: any, ctx: BaseContext): void;
@@ -1,6 +1,6 @@
1
1
  import { BaseContext } from "@tsed/di";
2
- import { Exception } from "@tsed/exceptions";
3
2
  import { ErrorFilter } from "./ErrorFilter.js";
3
+ import { Exception } from "@tsed/exceptions";
4
4
  export declare class ExceptionFilter extends ErrorFilter {
5
5
  catch(error: Exception, ctx: BaseContext): void;
6
6
  }
@@ -1,5 +1,5 @@
1
- import { Type } from "@tsed/core";
2
1
  import type { ExceptionFilterMethods } from "../interfaces/ExceptionFilterMethods.js";
2
+ import { Type } from "@tsed/core";
3
3
  /**
4
4
  * @ignore
5
5
  */
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@tsed/platform-exceptions",
3
+ "version": "8.36.0",
3
4
  "description": "Platform exceptions module for Ts.ED Framework",
4
- "type": "module",
5
- "version": "8.34.0",
6
5
  "source": "./src/index.ts",
6
+ "type": "module",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
9
9
  "typings": "./lib/types/index.d.ts",
@@ -25,14 +25,13 @@
25
25
  "tslib": ">=2.7.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@tsed/barrels": "8.34.0",
29
- "@tsed/core": "8.34.0",
30
- "@tsed/di": "8.34.0",
31
- "@tsed/exceptions": "8.34.0",
32
- "@tsed/schema": "8.34.0",
33
- "@tsed/typescript": "8.34.0",
28
+ "@tsed/barrels": "8.36.0",
29
+ "@tsed/core": "8.36.0",
30
+ "@tsed/di": "8.36.0",
31
+ "@tsed/exceptions": "8.36.0",
32
+ "@tsed/schema": "8.36.0",
33
+ "@tsed/typescript": "8.36.0",
34
34
  "ajv": "^8.17.1",
35
- "eslint": "9.12.0",
36
35
  "typescript": "6.0.2",
37
36
  "vitest": "4.1.4"
38
37
  },