Merge pull request #5021 from opf/fix/24193/attachment-error-handling

[24193] Wrap the non-$http response into an Error Resource
pull/5025/head
Oliver Günther 8 years ago committed by GitHub
commit 3c99292621
  1. 2
      frontend/app/components/api/api-v3/hal-resources/work-package-resource.service.test.ts
  2. 2
      frontend/app/components/api/api-v3/hal-resources/work-package-resource.service.ts
  3. 9
      frontend/app/components/wp-edit/wp-notification.service.ts

@ -303,7 +303,7 @@ describe('WorkPackageResource service', () => {
beforeEach(() => {
uploadFilesDeferred.reject(error);
notificationStub = sinon.stub(wpNotificationsService, 'handleErrorResponse');
notificationStub = sinon.stub(wpNotificationsService, 'handleRawError');
$rootScope.$apply();
});

@ -251,7 +251,7 @@ export class WorkPackageResource extends HalResource {
return this.updateAttachments();
})
.catch(error => {
wpNotificationsService.handleErrorResponse(error, this);
wpNotificationsService.handleRawError(error, this);
});
}

@ -53,6 +53,15 @@ export class WorkPackageNotificationService {
this.NotificationsService.addSuccess(message);
}
public handleRawError(response, workPackage?:WorkPackageResource) {
if (response && response.data && response.data._type === 'Error') {
const resource = new ErrorResource(response.data);
return this.handleErrorResponse(resource, workPackage);
}
this.showGeneralError();
}
public handleErrorResponse(errorResource, workPackage?:WorkPackageResource) {
if (!(errorResource instanceof ErrorResource)) {
return this.showGeneralError();

Loading…
Cancel
Save