@quanticdigit/web-errors 1.0.1 → 1.0.2
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.
- package/README.md +49 -36
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,64 +1,77 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @quanticdigit/web-errors
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Error collection and presentation: level aggregation, a localized dialog in 31 languages, pluggable
|
|
4
|
+
presenter.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
This is the implementation of `IErrorInfoAppender`, which `@quanticdigit/web-services` declares and
|
|
7
|
+
does not provide. The service layer knows **that** something went wrong; this knows **how to say it**.
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
## Install
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
|
-
|
|
12
|
+
npm install @quanticdigit/web-errors @quanticdigit/web-services
|
|
11
13
|
```
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
Peer dependencies: `@angular/core`, `devextreme`, `@quanticdigit/web-services`.
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
ng generate --help
|
|
17
|
-
```
|
|
17
|
+
## Use it
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
`ErrorCollector` is `providedIn: 'root'`. Hand it to any service call:
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
```ts
|
|
22
|
+
export class UserPage {
|
|
23
|
+
private readonly errors = inject(ErrorCollector);
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
load(): void {
|
|
26
|
+
this.users.byId(7, this.errors).subscribe((user) => …);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
25
29
|
```
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
Errors raised in the same turn are gathered into **one** dialog. Three failing calls produce three
|
|
32
|
+
lines, not three windows the user closes without reading.
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
## It already speaks your language
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
The texts ship with the package in the same 31 languages DevExtreme covers, so the dialog does not
|
|
37
|
+
come out in English surrounded by translated components. Nothing to configure.
|
|
32
38
|
|
|
33
|
-
|
|
39
|
+
## Three levels of customization
|
|
34
40
|
|
|
35
|
-
|
|
36
|
-
cd dist/web-errors
|
|
37
|
-
```
|
|
41
|
+
Nothing is mandatory. In order of weight:
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
npm publish
|
|
42
|
-
```
|
|
43
|
+
**One text.** Load that key into your own DevExtreme catalogue; it wins over the built-in one, and
|
|
44
|
+
the other seven stay as they are.
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
```ts
|
|
47
|
+
loadMessages({ it: { dialogTitleError: 'Ops' } });
|
|
48
|
+
```
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
**The window.** Declare `ERROR_PRESENTER` and ours is never even built.
|
|
47
51
|
|
|
48
|
-
```
|
|
49
|
-
|
|
52
|
+
```ts
|
|
53
|
+
{ provide: ERROR_PRESENTER, useValue: (p) => myDialog(p.title, p.message, p.errors) }
|
|
50
54
|
```
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
For end-to-end (e2e) testing, run:
|
|
56
|
+
To keep the default and add to it, wrap the exported one:
|
|
55
57
|
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
+
```ts
|
|
59
|
+
{ provide: ERROR_PRESENTER, useValue: (p) => { telemetry(p); devExtremeDialogPresenter(p); } }
|
|
58
60
|
```
|
|
59
61
|
|
|
60
|
-
|
|
62
|
+
**Everything.** Implement `IErrorInfoAppender` yourself and this package is not needed.
|
|
63
|
+
|
|
64
|
+
## A note on messages
|
|
65
|
+
|
|
66
|
+
`IErrorInfoModel.message` carries whatever the server put there. In products that resolve errors
|
|
67
|
+
through a copy catalogue it is a **key**, not a sentence: resolve it before handing it over, or the
|
|
68
|
+
key is what the user reads.
|
|
69
|
+
|
|
70
|
+
## The family
|
|
71
|
+
|
|
72
|
+
`web-utils`, `web-model`, `web-services`, `web-component` and `web-errors` are released together and
|
|
73
|
+
always share the same version. Install them at the same version.
|
|
61
74
|
|
|
62
|
-
##
|
|
75
|
+
## License
|
|
63
76
|
|
|
64
|
-
|
|
77
|
+
Commercial. See `LICENSE.txt` in the package.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quanticdigit/web-errors",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Error collection and presentation: level aggregation, a localized dialog in 31 languages, pluggable presenter.",
|
|
5
5
|
"author": "Quantic Digit S.R.L.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
7
7
|
"homepage": "https://www.quanticdigit.it/",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"@angular/core": "^21.2.0",
|
|
15
15
|
"devextreme": "^25.1.3",
|
|
16
|
-
"@quanticdigit/web-services": "1.0.
|
|
16
|
+
"@quanticdigit/web-services": "1.0.2"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"tslib": "^2.3.0"
|