mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-16 23:35:20 +01:00
Handle 504 error from backend
Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
parent
b2a53a7e51
commit
e999a15b02
@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpInterceptor, HttpRequest, HttpHandler, HttpResponse } from '@angular/common/http';
|
||||
import { HttpInterceptor, HttpRequest, HttpHandler, HttpResponse, HttpErrorResponse } from '@angular/common/http';
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { catchError, tap } from 'rxjs/operators';
|
||||
|
||||
@ -44,6 +44,14 @@ export class InterceptHttpService implements HttpInterceptor {
|
||||
}))
|
||||
.pipe(
|
||||
catchError(error => {
|
||||
// handle 504 error in document format from backend
|
||||
if (error && error.status === 504) {
|
||||
// throw 504 error in json format
|
||||
return throwError(new HttpErrorResponse({
|
||||
error: '504 gateway timeout',
|
||||
status: 504
|
||||
}));
|
||||
}
|
||||
if (error.status === 403) {
|
||||
const csrfToken = localStorage.getItem("__csrf");
|
||||
if (csrfToken) {
|
||||
|
Loading…
Reference in New Issue
Block a user