diff --git a/ui-ngx/src/app/core/interceptors/global-http-interceptor.ts b/ui-ngx/src/app/core/interceptors/global-http-interceptor.ts
index c210c54a0b..9d48e3b2ab 100644
--- a/ui-ngx/src/app/core/interceptors/global-http-interceptor.ts
+++ b/ui-ngx/src/app/core/interceptors/global-http-interceptor.ts
@@ -125,10 +125,6 @@ export class GlobalHttpInterceptor implements HttpInterceptor {
this.showError(req.method + ': ' + req.url + '
' +
errorResponse.status + ': ' + errorResponse.statusText);
}
- } else if (errorResponse.status === 504) {
- if (!ignoreErrors) {
- this.showError('Request timeout');
- }
} else {
unhandled = true;
}
diff --git a/ui-ngx/src/app/core/utils.ts b/ui-ngx/src/app/core/utils.ts
index 4c7a241931..348d4e7e9b 100644
--- a/ui-ngx/src/app/core/utils.ts
+++ b/ui-ngx/src/app/core/utils.ts
@@ -23,7 +23,7 @@ import { NULL_UUID } from '@shared/models/id/has-uuid';
import { baseDetailsPageByEntityType, EntityType } from '@shared/models/entity-type.models';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { TranslateService } from '@ngx-translate/core';
-import { serverErrorCodesTranslations } from '@shared/models/constants';
+import { httpStatusMessageMap, serverErrorCodesTranslations } from '@shared/models/constants';
import { SubscriptionEntityInfo } from '@core/api/widget-api.models';
import {
CompiledTbFunction,
@@ -825,11 +825,13 @@ export function parseHttpErrorMessage(errorResponse: HttpErrorResponse,
} else {
error = errorResponse.error;
}
- if (error && !error.message) {
- errorMessage = prepareMessageFromData(error);
- } else if (error && error.message) {
+ if (error && error.message) {
errorMessage = error.message;
timeout = error.timeout ? error.timeout : 0;
+ } else if (isProxyError(errorResponse)) {
+ errorMessage = httpStatusMessageMap.get(errorResponse.status);
+ } else if (error) {
+ errorMessage = prepareMessageFromData(error);
} else {
errorMessage = `Unhandled error code ${error ? error.status : '\'Unknown\''}`;
}
@@ -866,6 +868,14 @@ function prepareMessageFromData(data): string {
}
}
+function isProxyError(errorResponse: HttpErrorResponse): boolean {
+ if (!httpStatusMessageMap.has(errorResponse.status)) {
+ return false;
+ }
+ const error = errorResponse.error;
+ return !error || typeof error === 'string' || (typeof error === 'object' && !error.message);
+}
+
export const genNextLabel = (name: string, datasources: Datasource[]): string => {
let label = name;
let i = 1;
diff --git a/ui-ngx/src/app/shared/models/constants.ts b/ui-ngx/src/app/shared/models/constants.ts
index 9f3889d277..429bfe217a 100644
--- a/ui-ngx/src/app/shared/models/constants.ts
+++ b/ui-ngx/src/app/shared/models/constants.ts
@@ -54,6 +54,12 @@ export const serverErrorCodesTranslations = new Map([
[Constants.serverErrorCode.tooManyUpdates, 'server-error.too-many-updates'],
]);
+export const httpStatusMessageMap = new Map([
+ [502, 'Server is temporarily unavailable (Bad Gateway)'],
+ [503, 'Server is temporarily unavailable'],
+ [504, 'Server did not respond in time (Gateway Timeout)'],
+]);
+
export const MediaBreakpoints = {
xs: 'screen and (max-width: 599px)',
sm: 'screen and (min-width: 600px) and (max-width: 959px)',