From e999a15b02a40b4468de0ea0154e29fd1e0f33d1 Mon Sep 17 00:00:00 2001 From: AllForNothing Date: Mon, 28 Sep 2020 18:08:25 +0800 Subject: [PATCH] Handle 504 error from backend Signed-off-by: AllForNothing --- src/portal/src/app/services/intercept-http.service.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/portal/src/app/services/intercept-http.service.ts b/src/portal/src/app/services/intercept-http.service.ts index a72dac71a..9b73a48a3 100644 --- a/src/portal/src/app/services/intercept-http.service.ts +++ b/src/portal/src/app/services/intercept-http.service.ts @@ -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) {