DG
// error-from-selector.ts
export class ErrorFromSelector extends Error {}
// selectors.ts
const mySelector = createSelector(store, (state) => {
if(__sluchilas_beda__) {
throw new ErrorFromSelector("beda");
}
});
// error-handler.ts (https://angular.io/api/core/ErrorHandler)
class MyErrorHandler implements ErrorHandler {
constructor(private store: Store){}
handleError(error: Error) {
if(error instanceof ErrorFromSelector) {
this.store.dispatch(new ErrorFromSelectorAction(error));
}
}
}
// app.module.ts
@NgModule({
providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
})
class AppModule {}