@tc-libs/errors 3.5.0 → 3.6.1

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.
Files changed (2) hide show
  1. package/README.md +63 -6
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,11 +1,68 @@
1
- # errors
1
+ # @tc-libs/errors
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ Catalogo di errori custom del monorepo.
4
4
 
5
- ## Building
5
+ Il package contiene:
6
6
 
7
- Run `nx build errors` to build the library.
7
+ - errori HTTP derivati da `ApiError`
8
+ - errori applicativi puri (`AppError`)
9
+ - errori di connessione/database/queue
10
+ - interfacce di supporto
8
11
 
9
- ## Running unit tests
12
+ ## Struttura
10
13
 
11
- Run `nx test errors` to execute the unit tests via [Jest](https://jestjs.io).
14
+ Le cartelle `api/400`, `api/401`, `api/403`, ecc. espongono classi gia pronte per gli status code piu comuni.
15
+
16
+ Esempi di uso reale nel monorepo:
17
+
18
+ - `Api422ValidationError`
19
+ - `Api401JWTAccessTokenUnauthorizedError`
20
+ - `Api403AccessForError`
21
+ - `Api404EntityNotFoundError`
22
+ - `Api415UnsupportedMediaTypeError`
23
+ - `Api408RequestTimeoutError`
24
+
25
+ ## Base class
26
+
27
+ ### `ApiError`
28
+
29
+ Estende `HttpException` e aggiunge:
30
+
31
+ - `type`
32
+ - `description`
33
+ - `data`
34
+ - `hasToLogConsole`
35
+
36
+ Esempio:
37
+
38
+ ```ts
39
+ throw new Api404EntityNotFoundError({ entity: 'User' });
40
+ ```
41
+
42
+ ### `AppError`
43
+
44
+ Errore applicativo non HTTP, utile nel bootstrap o in flussi interni:
45
+
46
+ ```ts
47
+ throw new AppMissingPortError();
48
+ ```
49
+
50
+ ## Quando usarlo
51
+
52
+ Usa questo package quando vuoi:
53
+
54
+ - lanciare errori HTTP coerenti con il formato atteso da `@tc-libs/error-handler`
55
+ - evitare `throw new HttpException(...)` sparsi nel codice
56
+ - standardizzare i message path usati da `@tc-libs/message`
57
+
58
+ ## Note operative
59
+
60
+ - Gli handler e filtri del monorepo si aspettano eccezioni derivate da `ApiError` per arricchire la risposta.
61
+ - Le classi sono numerose: conviene importare solo gli errori che ti servono.
62
+
63
+ ## Sviluppo
64
+
65
+ ```bash
66
+ nx build errors
67
+ nx test errors
68
+ ```
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@tc-libs/errors",
3
- "version": "3.5.0",
3
+ "version": "3.6.1",
4
4
  "dependencies": {
5
- "@tc-libs/error-interface": "3.5.0",
5
+ "@tc-libs/error-interface": "3.6.1",
6
6
  "@nestjs/common": "^11.0.12",
7
7
  "class-validator": "^0.14.1",
8
8
  "tslib": "^2.8.1"