Error Handling
Singleton provides two error streams for users to listen to that emit objects of type VIPError.
- errors$ on subscription will emit all errors emitted up to this point and each new error after that.
- lastError$ on subscription will emit last error emitted up to this point and each new error after that.
export interface VIPError {
code: VIPErrorCode; // custom code representing the type of failure that occurred
data: VIPErrorData; // custom data related to the specific error type
error: any; // api error response if such exists
}
User can listen through VIPService instance:
// user-app.ts
this.vipService.errors$.subscribe(error => {
if (error.code === VIPErrorCode.ComponentLoadFailure) {
// handle errors
}
});
this.vipService.lastError$.subscribe(error => {
if (error.code === VIPErrorCode.ComponentLoadFailure) {
// handle last error
}
});