Refactor environment variables.

This commit is contained in:
Spencer Ofwiti
2021-03-16 18:32:26 +03:00
parent 03be46e169
commit 124a6bf295
4 changed files with 19 additions and 22 deletions

View File

@@ -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);
}