Advanced Cluster Management - NGUI
- Added new OKA packages module under packages
- Added Profiless, KSU under k8s section
- Feature 11020. 11022, 11023, 11024, 11025, 11026
Change-Id: Ibddeb4d5693ce24d80e378277693405c810f6e04
Signed-off-by: SANDHYA.JS <sandhya.j@tataelxsi.co.in>
diff --git a/src/services/RestService.ts b/src/services/RestService.ts
index e333627..ea1a5c3 100644
--- a/src/services/RestService.ts
+++ b/src/services/RestService.ts
@@ -28,6 +28,7 @@
import { APIURLHEADER, ERRORDATA } from 'CommonModel';
import * as HttpStatus from 'http-status-codes';
import { Observable } from 'rxjs';
+import { isNullOrUndefined } from 'SharedService';
/**
* An Injectable is a class adorned with the @Injectable decorator function.
@@ -136,43 +137,41 @@
* @param method The http request method.
*/
public handleError(err: ERRORDATA, method?: string): void {
- if (err.error.status === HttpStatus.UNAUTHORIZED) {
- if (method !== 'get') {
- if (err.error.detail !== 'Expired Token or Authorization HTTP header' &&
- err.error.detail !== 'Invalid Token or Authorization HTTP header') {
- this.notifierService.notify('error', err.error.detail !== undefined ?
- err.error.detail : this.translateService.instant('HTTPERROR.401'));
+ const errStatus = {
+ 400: this.translateService.instant('HTTPERROR.400'),
+ 401: this.translateService.instant('HTTPERROR.401'),
+ 404: this.translateService.instant('HTTPERROR.404'),
+ 409: this.translateService.instant('HTTPERROR.409'),
+ 500: this.translateService.instant('HTTPERROR.500'),
+ 502: this.translateService.instant('HTTPERROR.502'),
+ 503: this.translateService.instant('HTTPERROR.503'),
+ 504: this.translateService.instant('HTTPERROR.504')
+ };
+ if (!this.isNullOrUndefined(err)) {
+ if (err.error.status === HttpStatus.UNAUTHORIZED) {
+ if (!this.isNullOrUndefined(method)) {
+ if (method !== 'get') {
+ if (err.error.detail !== 'Expired Token or Authorization HTTP header' &&
+ err.error.detail !== 'Invalid Token or Authorization HTTP header') {
+ this.notifierService.notify('error', err.error.detail !== undefined ?
+ err.error.detail : this.translateService.instant('HTTPERROR.401'));
+ }
+ this.activeModal.dismissAll();
+ }
}
+ } else if (err.error.status === HttpStatus.CONFLICT) {
+ this.notifierService.notify('error', err.error.detail !== undefined ?
+ err.error.detail : this.translateService.instant('HTTPERROR.409'));
+ if (sessionStorage.getItem('usertype') !== 'change_password') {
+ this.activeModal.dismissAll();
+ }
+ } else if (!isNullOrUndefined(errStatus[err.error.status])) {
+ this.notifierService.notify('error', err.error.detail !== undefined ?
+ err.error.detail : errStatus[err.error.status]);
} else {
- this.notifierService.notify('error', err?.error?.detail !== undefined ?
- err?.error?.detail : this.translateService.instant('HTTPERROR.401'));
+ this.notifierService.notify('error', err.error.detail !== undefined ?
+ err.error.detail : this.translateService.instant('ERROR'));
}
- this.activeModal.dismissAll();
- } else if (err.error.status === HttpStatus.BAD_REQUEST) {
- this.notifierService.notify('error', err.error.detail !== undefined ?
- err.error.detail : this.translateService.instant('HTTPERROR.400'));
- } else if (err.error.status === HttpStatus.NOT_FOUND) {
- this.notifierService.notify('error', err.error.detail !== undefined ?
- err.error.detail : this.translateService.instant('HTTPERROR.404'));
- } else if (err.error.status === HttpStatus.CONFLICT) {
- this.notifierService.notify('error', err.error.detail !== undefined ?
- err.error.detail : this.translateService.instant('HTTPERROR.409'));
- if (sessionStorage.getItem('usertype') !== 'change_password') {
- this.activeModal.dismissAll();
- }
- this.activeModal.dismissAll();
- } else if (err.error.status === HttpStatus.INTERNAL_SERVER_ERROR) {
- this.notifierService.notify('error', err.error.detail !== undefined ?
- err.error.detail : this.translateService.instant('HTTPERROR.500'));
- } else if (err.error.status === HttpStatus.BAD_GATEWAY) {
- this.notifierService.notify('error', this.translateService.instant('HTTPERROR.502'));
- } else if (err.error.status === HttpStatus.SERVICE_UNAVAILABLE) {
- this.notifierService.notify('error', this.translateService.instant('HTTPERROR.503'));
- } else if (err.error.status === HttpStatus.GATEWAY_TIMEOUT) {
- this.notifierService.notify('error', this.translateService.instant('HTTPERROR.504'));
- } else {
- this.notifierService.notify('error', err.error.detail !== undefined ?
- err.error.detail : this.translateService.instant('ERROR'));
}
}