@quanticdigit/web-errors
v1.0.2
Published
Error collection and presentation: level aggregation, a localized dialog in 31 languages, pluggable presenter.
Readme
@quanticdigit/web-errors
Error collection and presentation: level aggregation, a localized dialog in 31 languages, pluggable presenter.
This is the implementation of IErrorInfoAppender, which @quanticdigit/web-services declares and
does not provide. The service layer knows that something went wrong; this knows how to say it.
Install
npm install @quanticdigit/web-errors @quanticdigit/web-servicesPeer dependencies: @angular/core, devextreme, @quanticdigit/web-services.
Use it
ErrorCollector is providedIn: 'root'. Hand it to any service call:
export class UserPage {
private readonly errors = inject(ErrorCollector);
load(): void {
this.users.byId(7, this.errors).subscribe((user) => …);
}
}Errors raised in the same turn are gathered into one dialog. Three failing calls produce three lines, not three windows the user closes without reading.
It already speaks your language
The texts ship with the package in the same 31 languages DevExtreme covers, so the dialog does not come out in English surrounded by translated components. Nothing to configure.
Three levels of customization
Nothing is mandatory. In order of weight:
One text. Load that key into your own DevExtreme catalogue; it wins over the built-in one, and the other seven stay as they are.
loadMessages({ it: { dialogTitleError: 'Ops' } });The window. Declare ERROR_PRESENTER and ours is never even built.
{ provide: ERROR_PRESENTER, useValue: (p) => myDialog(p.title, p.message, p.errors) }To keep the default and add to it, wrap the exported one:
{ provide: ERROR_PRESENTER, useValue: (p) => { telemetry(p); devExtremeDialogPresenter(p); } }Everything. Implement IErrorInfoAppender yourself and this package is not needed.
A note on messages
IErrorInfoModel.message carries whatever the server put there. In products that resolve errors
through a copy catalogue it is a key, not a sentence: resolve it before handing it over, or the
key is what the user reads.
The family
web-utils, web-model, web-services, web-component and web-errors are released together and
always share the same version. Install them at the same version.
License
Commercial. See LICENSE.txt in the package.
