Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit dafa1fc

Browse files
oodamienghillert
authored andcommitted
HTTP error / ErrorHandler improvements
Resolves #755 #662
1 parent 6d3dc92 commit dafa1fc

33 files changed

+406
-141
lines changed

ui/src/app/analytics/analytics.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { AggregateCounter, BaseCounter, Counter, DashboardItem, FieldValueCounte
1111
import { HttpUtils } from '../shared/support/http.utils';
1212
import { NotificationService } from '../shared/services/notification.service';
1313
import { LoggerService } from '../shared/services/logger.service';
14+
import { AppError } from '../shared/model/error.model';
1415

1516
/**
1617
* @author Gunnar Hillert
@@ -90,7 +91,7 @@ export class AnalyticsService {
9091
result => {
9192
},
9293
error => {
93-
this.notificationService.error(error);
94+
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
9495
});
9596
}
9697
}
@@ -338,9 +339,8 @@ export class AnalyticsService {
338339
result => resultProcessor(result),
339340
error => {
340341
this.loggerService.log('error', error);
341-
this.notificationService.error(error);
342-
}
343-
);
342+
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
343+
});
344344
}
345345
}
346346

ui/src/app/analytics/dashboard/dashboard.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { takeUntil } from 'rxjs/operators';
55
import { Subject } from 'rxjs/Subject';
66
import { NotificationService } from '../../shared/services/notification.service';
77
import { LoggerService } from '../../shared/services/logger.service';
8+
import { AppError } from '../../shared/model/error.model';
89

910
/**
1011
* The dashboard component provides
@@ -120,7 +121,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
120121
dashBoardItem.counters = result.items;
121122
},
122123
error => {
123-
this.notificationService.error(error);
124+
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
124125
});
125126
}
126127

ui/src/app/apps/app-details/app-details.component.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { BusyService } from '../../shared/services/busy.service';
1616
import { RoutingStateService } from '../../shared/services/routing-state.service';
1717
import { NotificationService } from '../../shared/services/notification.service';
1818
import { LoggerService } from '../../shared/services/logger.service';
19+
import { HttpAppError, AppError } from '../../shared/model/error.model';
1920

2021
/**
2122
* Provides details for an App Registration
@@ -75,7 +76,6 @@ export class AppDetailsComponent implements OnInit, OnDestroy {
7576
* @param {AppsService} appsService
7677
* @param {SharedAboutService} sharedAboutService
7778
* @param {NotificationService} notificationService
78-
* @param {Router} router
7979
* @param {ActivatedRoute} route
8080
* @param {RoutingStateService} routingStateService
8181
* @param {BusyService} busyService
@@ -85,7 +85,6 @@ export class AppDetailsComponent implements OnInit, OnDestroy {
8585
constructor(private appsService: AppsService,
8686
private sharedAboutService: SharedAboutService,
8787
private notificationService: NotificationService,
88-
private router: Router,
8988
private route: ActivatedRoute,
9089
private routingStateService: RoutingStateService,
9190
private busyService: BusyService,
@@ -98,13 +97,15 @@ export class AppDetailsComponent implements OnInit, OnDestroy {
9897
*/
9998
ngOnInit() {
10099
this.loggerService.log('App Service Details');
101-
this.sharedAboutService.getFeatureInfo().pipe(combineLatest(this.route.params)).subscribe((data: any[]) => {
102-
const featureInfo = data[0] as FeatureInfo;
103-
const params = data[1] as Params;
104-
this.application = new AppRegistration(params['appName'], params['appType'] as ApplicationType);
105-
this.skipperEnabled = featureInfo.skipperEnabled;
106-
this.refresh();
107-
});
100+
this.sharedAboutService.getFeatureInfo()
101+
.pipe(combineLatest(this.route.params))
102+
.subscribe((data: any[]) => {
103+
const featureInfo = data[0] as FeatureInfo;
104+
const params = data[1] as Params;
105+
this.application = new AppRegistration(params['appName'], params['appType'] as ApplicationType);
106+
this.skipperEnabled = featureInfo.skipperEnabled;
107+
this.refresh();
108+
});
108109
}
109110

110111
/**
@@ -143,7 +144,10 @@ export class AppDetailsComponent implements OnInit, OnDestroy {
143144
this.detailedAppRegistration = detailed;
144145
},
145146
error => {
146-
this.notificationService.error(error);
147+
if (HttpAppError.is404(error)) {
148+
this.cancel();
149+
}
150+
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
147151
});
148152

149153
this.busyService.addSubscription(busy);
@@ -158,18 +162,22 @@ export class AppDetailsComponent implements OnInit, OnDestroy {
158162
.getAppVersions(ApplicationType[this.application.type.toString()], this.application.name)
159163
.pipe(takeUntil(this.ngUnsubscribe$))
160164
.subscribe((data: any) => {
161-
this.application.versions = data;
162-
this.defaultVersion = this.application.versions.find((a) => a.defaultVersion);
163-
if (this.defaultVersion) {
164-
this.application.version = this.defaultVersion.version;
165-
this.application.uri = this.defaultVersion.uri;
166-
this.selectVersion(this.defaultVersion.version);
165+
if (data.length > 0) {
166+
this.application.versions = data;
167+
this.defaultVersion = this.application.versions.find((a) => a.defaultVersion);
168+
if (this.defaultVersion) {
169+
this.application.version = this.defaultVersion.version;
170+
this.application.uri = this.defaultVersion.uri;
171+
this.selectVersion(this.defaultVersion.version);
172+
} else {
173+
this.selectVersion(this.application.versions[0].version);
174+
}
167175
} else {
168-
this.selectVersion(this.application.versions[0].version);
176+
this.loadProperties();
169177
}
170178
},
171179
error => {
172-
this.notificationService.error(error);
180+
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
173181
});
174182

175183
this.busyService.addSubscription(busy);

ui/src/app/apps/app-versions/app-versions.component.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
import {Component, EventEmitter, OnDestroy} from '@angular/core';
2-
import {Subscription} from 'rxjs/Subscription';
3-
import {AppRegistration} from '../../shared/model/app-registration.model';
4-
import {AppsService} from '../apps.service';
5-
import {ConfirmService} from '../../shared/components/confirm/confirm.service';
6-
import {BsModalRef} from 'ngx-bootstrap';
7-
import {AppVersion} from '../../shared/model/app-version';
8-
import {SortParams, OrderParams} from '../../shared/components/shared.interface';
9-
import {Subject} from 'rxjs/Subject';
10-
import {takeUntil} from 'rxjs/operators';
11-
import {BusyService} from '../../shared/services/busy.service';
12-
import {ApplicationType} from '../../shared/model/application-type';
1+
import { Component, EventEmitter, OnDestroy } from '@angular/core';
2+
import { Subscription } from 'rxjs/Subscription';
3+
import { AppRegistration } from '../../shared/model/app-registration.model';
4+
import { AppsService } from '../apps.service';
5+
import { ConfirmService } from '../../shared/components/confirm/confirm.service';
6+
import { BsModalRef } from 'ngx-bootstrap';
7+
import { AppVersion } from '../../shared/model/app-version';
8+
import { SortParams, OrderParams } from '../../shared/components/shared.interface';
9+
import { Subject } from 'rxjs/Subject';
10+
import { takeUntil } from 'rxjs/operators';
11+
import { BusyService } from '../../shared/services/busy.service';
12+
import { ApplicationType } from '../../shared/model/application-type';
1313
import { NotificationService } from '../../shared/services/notification.service';
1414
import { LoggerService } from '../../shared/services/logger.service';
15+
import { AppError } from '../../shared/model/error.model';
1516

1617
/**
1718
* Provides versions for an App Registration
@@ -172,7 +173,7 @@ export class AppVersionsComponent implements OnDestroy {
172173
`of the application <strong>${this.application.name}</strong> (${this.application.type}). This version ` +
173174
` is the <strong>default version</strong>. Are you sure?`;
174175
}
175-
this.confirmService.open(title, description, {confirm: 'Unregister version'}).subscribe(() => {
176+
this.confirmService.open(title, description, { confirm: 'Unregister version' }).subscribe(() => {
176177
this.appsService.unregisterAppVersion(this.application, version.version).subscribe(() => {
177178
this.notificationService.success(`The version <strong>${version.version}</strong> of the application ` +
178179
`<strong>${this.application.name}</strong> (${this.application.type}) has been unregister.`);
@@ -185,7 +186,7 @@ export class AppVersionsComponent implements OnDestroy {
185186
this.event.emit(true);
186187
},
187188
error => {
188-
this.notificationService.error(error);
189+
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
189190
});
190191
});
191192
}

ui/src/app/apps/apps-register/apps-register.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {BusyService} from '../../shared/services/busy.service';
1212
import {takeUntil} from 'rxjs/operators';
1313
import { NotificationService } from '../../shared/services/notification.service';
1414
import { LoggerService } from '../../shared/services/logger.service';
15+
import { AppError } from '../../shared/model/error.model';
1516

1617
/**
1718
* Applications Register
@@ -102,7 +103,7 @@ export class AppsRegisterComponent implements OnInit, OnDestroy {
102103
this.cancel();
103104
},
104105
error => {
105-
this.notificationService.error(error);
106+
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
106107
}
107108
);
108109

ui/src/app/apps/apps-unregister/apps-unregister.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {AppsService} from '../apps.service';
55
import 'rxjs/add/observable/throw';
66
import { NotificationService } from '../../shared/services/notification.service';
77
import { LoggerService } from '../../shared/services/logger.service';
8+
import { AppError } from '../../shared/model/error.model';
89

910
/**
1011
* Applications Unregister modal
@@ -71,7 +72,7 @@ export class AppsUnregisterComponent {
7172
this.event.emit(data);
7273
this.close();
7374
}, error => {
74-
this.notificationService.error(error);
75+
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
7576
this.close();
7677
});
7778
}

ui/src/app/apps/apps/apps.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { takeUntil } from 'rxjs/operators';
1515
import { BusyService } from '../../shared/services/busy.service';
1616
import { NotificationService } from '../../shared/services/notification.service';
1717
import { LoggerService } from '../../shared/services/logger.service';
18+
import { AppError } from '../../shared/model/error.model';
1819

1920
/**
2021
* Main entry point to the Apps Module. Provides
@@ -158,9 +159,8 @@ export class AppsComponent implements OnInit, OnDestroy {
158159
this.updateContext();
159160
},
160161
error => {
161-
this.notificationService.error(error);
162-
}
163-
);
162+
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
163+
});
164164

165165
this.busyService.addSubscription(busy);
166166
}

ui/src/app/auth/login.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { BusyService } from '../shared/services/busy.service';
1010
import { takeUntil } from 'rxjs/operators';
1111
import { NotificationService } from '../shared/services/notification.service';
1212
import { LoggerService } from '../shared/services/logger.service';
13+
import { AppError } from '../shared/model/error.model';
1314

1415
/**
1516
* Handles application logins.
@@ -73,7 +74,7 @@ export class LoginComponent implements OnInit, OnDestroy {
7374
},
7475
error => {
7576
this.loggerService.error('User was not logged in because:', error);
76-
this.notificationService.error(error);
77+
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
7778
}
7879
);
7980
} else {
@@ -82,7 +83,7 @@ export class LoginComponent implements OnInit, OnDestroy {
8283
}
8384
},
8485
error => {
85-
this.notificationService.error(error);
86+
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
8687
});
8788
this.busyService.addSubscription(busy);
8889
}

ui/src/app/auth/logout.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { takeUntil } from 'rxjs/operators';
77
import { Subject } from 'rxjs/Subject';
88
import { NotificationService } from '../shared/services/notification.service';
99
import { LoggerService } from '../shared/services/logger.service';
10+
import { AppError } from '../shared/model/error.model';
1011

1112
/**
1213
* Handles logouts. Logouts are handled differently depending on whether
@@ -56,7 +57,7 @@ export class LogoutComponent implements OnInit, OnDestroy {
5657
},
5758
error => {
5859
this.aboutService.featureInfo.reset();
59-
this.notificationService.error(error);
60+
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
6061
},
6162
);
6263
} else {

ui/src/app/jobs/job-execution-details/job-execution-details.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ <h4>Steps</h4>
121121
</div>
122122

123123
<div class="text-center">
124-
<button type="button" class="btn btn-default" (click)="back()">Back</button>
124+
<button id="button-back" type="button" class="btn btn-default" (click)="back()">Back</button>
125125
</div>
126126

127127
</div>

0 commit comments

Comments
 (0)