Add wpNotificationService helper method to handle error responses

pull/4605/head
Oliver Günther 8 years ago
parent 85d4b319a8
commit 667dcdde52
  1. 8
      frontend/app/components/wp-edit/wp-notification.service.ts

@ -28,6 +28,7 @@
import {openprojectModule} from '../../angular-modules';
import {WorkPackageResourceInterface} from '../api/api-v3/hal-resources/work-package-resource.service';
import {ErrorResource} from '../api/api-v3/hal-resources/error-resource.service';
export class WorkPackageNotificationService {
constructor(protected I18n,
@ -49,6 +50,13 @@ export class WorkPackageNotificationService {
this.NotificationsService.addSuccess(message);
}
public handleErrorResponse(error, workPackage) {
if (!(error.data instanceof ErrorResource)) {
return this.showGeneralError();
}
this.showError(error.data, workPackage);
}
public showError(errorResource, workPackage) {
this.showCustomError(errorResource, workPackage) || this.showApiErrorMessages(errorResource);
}

Loading…
Cancel
Save