Refactor environment variables.
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
import {Observable, throwError} from 'rxjs';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
import {ErrorDialogService} from '@app/_services';
|
||||
import {environment} from '@src/environments/environment';
|
||||
|
||||
@Injectable()
|
||||
export class ErrorInterceptor implements HttpInterceptor {
|
||||
@@ -16,10 +17,12 @@ export class ErrorInterceptor implements HttpInterceptor {
|
||||
|
||||
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
|
||||
return next.handle(request).pipe(catchError((err: HttpErrorResponse) => {
|
||||
this.errorDialogService.openDialog({
|
||||
message: err.error.message || err.statusText,
|
||||
status: err.status
|
||||
});
|
||||
if (!environment.production) {
|
||||
this.errorDialogService.openDialog({
|
||||
message: err.error.message || err.statusText || 'Unknown Error',
|
||||
status: err.status || 0
|
||||
});
|
||||
}
|
||||
if ([401, 403].indexOf(err.status) !== -1) {
|
||||
location.reload(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user