RED-7558: backport generic errors.
This commit is contained in:
parent
7312caa8d0
commit
d6f7122329
@ -1,9 +1,10 @@
|
||||
import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpStatusCode } from '@angular/common/http';
|
||||
import { inject, Inject, Injectable, Optional } from '@angular/core';
|
||||
import { MonoTypeOperatorFunction, Observable, retry, throwError, timer } from 'rxjs';
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { finalize, MonoTypeOperatorFunction, Observable, retry, throwError, timer } from 'rxjs';
|
||||
import { catchError, tap } from 'rxjs/operators';
|
||||
import { MAX_RETRIES_ON_SERVER_ERROR, SERVER_ERROR_SKIP_PATHS } from './tokens';
|
||||
import { ErrorService } from './error.service';
|
||||
import { LoadingService } from '../loading';
|
||||
import { KeycloakService } from 'keycloak-angular';
|
||||
import { IqserConfigService } from '../services';
|
||||
|
||||
@ -49,6 +50,7 @@ export class ServerErrorInterceptor implements HttpInterceptor {
|
||||
private readonly _errorService: ErrorService,
|
||||
private readonly _keycloakService: KeycloakService,
|
||||
private readonly _configService: IqserConfigService,
|
||||
private readonly _loadingService: LoadingService,
|
||||
@Optional() @Inject(MAX_RETRIES_ON_SERVER_ERROR) private readonly _maxRetries: number,
|
||||
@Optional() @Inject(SERVER_ERROR_SKIP_PATHS) private readonly _skippedPaths: string[],
|
||||
) {}
|
||||
@ -70,7 +72,11 @@ export class ServerErrorInterceptor implements HttpInterceptor {
|
||||
this._urlsWithError.add(req.url);
|
||||
}
|
||||
|
||||
return throwError(() => error);
|
||||
return throwError(() => error).pipe(
|
||||
finalize(() => {
|
||||
this._loadingService.stop();
|
||||
}),
|
||||
);
|
||||
}),
|
||||
backoffOnServerError(this._maxRetries, this._skippedPaths),
|
||||
tap(() => {
|
||||
|
||||
@ -62,6 +62,10 @@ export class Toaster {
|
||||
return this._toastr.error(resultedMsg, options?.title, options);
|
||||
}
|
||||
|
||||
rawError(message: string, config?: Partial<IndividualConfig<unknown>>) {
|
||||
return this._toastr.error(message, undefined, config);
|
||||
}
|
||||
|
||||
info(message: string, options?: Partial<ToasterOptions>): ActiveToast<unknown> {
|
||||
return this._showToastNotification(message, NotificationType.INFO, options);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user