A dictionary of human-readable errors, grouped locales.
Translated human-readable error with hints to the user.
The locale id, provided by LOCALE_ID injection token, according to the angular i18n
Lowercase ASCII error message, identifying the error. For example 'not found', 'service unavailable', etc.
Just a simple assert, cos there is none in the browser standard lib
value to be asserted
assertion message
Safely transforms any error into the text. Prepares message to be the field of the JSON message.
Used to mark unreachable code statements. For example:
function boatCapacity(type: 'long' | 'short'): number {
if (type === 'long') {
return 16
} else if (type === 'short') {
return 4
} else {
return unreachable('unknown boat type')
}
}
a error message to be thrown
Generated using TypeDoc
Usage:
Install
Write the config ErrorsConfig.
Import ErrorsModule.forRoot(config) once in your app.
If you wish to report unhandled errors, add
to the app.module providers array.
Use
ErrorsService
, available across the app, to report and transform errors.Stick to the conventions, described below.
Convention: all errors, thrown by the request function (an http request or a socket request), have a string type and are a human-readable messages, understandable by the user. To do so, pipe request observable through ErrorsService.toUserError. All errors should be reported to the server. Errors, thrown by the request function, are handled using ErrorsService.reportError
Another convention is to handle errors, thrown by the request functions, inside effects, and map them into NgRx actions. Example:
OrdersEffects
And then display the error inside an effect or inside a component.
For errors, that were not handled inside the observable, custom error handler ErrorsHandler is written. It catches Every error in the app and send the report.