Fix error resource handling

pull/4734/head
Alex Dik 8 years ago
parent 4ac4e27496
commit 4c5eae5b2d
  1. 2
      frontend/app/components/api/api-v3/hal-resources/work-package-resource.service.ts
  2. 9
      frontend/app/components/work-packages/work-package-comment/work-package-comment.directive.ts
  3. 4
      frontend/app/components/work-packages/wp-display-attr/wp-display-attr.directive.ts
  4. 5
      frontend/app/components/wp-edit/wp-edit-form.directive.ts
  5. 3
      frontend/app/components/wp-edit/wp-notification.service.ts
  6. 21
      frontend/app/components/wp-relations/wp-relation-group/wp-parent-relation-group.service.ts

@ -201,7 +201,7 @@ export class WorkPackageResource extends HalResource {
public getForm() {
if (!this.form) {
this.updateForm(this.$source).catch(error => {
NotificationsService.addError(error.data.message);
NotificationsService.addError(error.message);
});
}

@ -32,8 +32,8 @@ import {WorkPackageCommentField} from './wp-comment-field.module';
import {ErrorResource} from '../../api/api-v3/hal-resources/error-resource.service';
import {WorkPackageNotificationService} from '../../wp-edit/wp-notification.service';
import {WorkPackageCacheService} from '../work-package-cache.service';
export class CommentFieldDirectiveController {
export class CommentFieldDirectiveController {
public workPackage:WorkPackageResourceInterface;
public field:WorkPackageCommentField;
public loadingPromise:ng.IPromise<any>;
@ -112,9 +112,10 @@ export class CommentFieldDirectiveController {
});
})
.catch(error => {
if (error.data instanceof ErrorResource) {
this.wpNotificationsService.showError(error.data, this.workPackage);
} else {
if (error instanceof ErrorResource) {
this.wpNotificationsService.showError(error, this.workPackage);
}
else {
this.NotificationsService.addError(this.I18n.t('js.work_packages.comment_send_failed'));
}
})

@ -89,9 +89,7 @@ export class WorkPackageDisplayAttributeController {
if (this.isEmpty) {
return this.placeholder;
}
else {
return this.field.valueString;
}
return this.field.valueString;
}
protected updateAttribute(wp) {

@ -134,8 +134,8 @@ export class WorkPackageEditFormController {
})
.catch((error) => {
this.wpNotificationsService.handleErrorResponse(error, this.workPackage);
if (error.data instanceof ErrorResource) {
this.handleSubmissionErrors(error.data, deferred);
if (error instanceof ErrorResource) {
this.handleSubmissionErrors(error, deferred);
}
});
@ -143,7 +143,6 @@ export class WorkPackageEditFormController {
}
private handleSubmissionErrors(error:any, deferred:any) {
// Process single API errors
this.handleErroneousAttributes(error);
return deferred.reject();

@ -53,8 +53,7 @@ export class WorkPackageNotificationService {
this.NotificationsService.addSuccess(message);
}
public handleErrorResponse(error, workPackage?:WorkPackageResource) {
const errorResource = error.data;
public handleErrorResponse(errorResource, workPackage?:WorkPackageResource) {
if (!(errorResource instanceof ErrorResource)) {
return this.showGeneralError();
}

@ -28,20 +28,15 @@
import {WorkPackageRelationGroup} from './wp-relation-group.service';
import {wpTabsModule} from '../../../angular-modules';
import {WorkPackageCacheService} from "../../work-packages/work-package-cache.service";
import {
WorkPackageResource,
WorkPackageResourceInterface
} from "../../api/api-v3/hal-resources/work-package-resource.service";
import {WorkPackageNotificationService} from "../../wp-edit/wp-notification.service";
import {ErrorResource} from "../../api/api-v3/hal-resources/error-resource.service";
import {WorkPackageCacheService} from '../../work-packages/work-package-cache.service';
import {WorkPackageNotificationService} from '../../wp-edit/wp-notification.service';
import {ErrorResource} from '../../api/api-v3/hal-resources/error-resource.service';
var $q:ng.IQService;
var HalResource;
var PathHelper:any;
var wpCacheService:WorkPackageCacheService;
var wpNotificationsService:WorkPackageNotificationService;
var $q:ng.IQService;
export class WorkPackageParentRelationGroup extends WorkPackageRelationGroup {
public get canAddRelation():boolean {
@ -85,9 +80,10 @@ export class WorkPackageParentRelationGroup extends WorkPackageRelationGroup {
return wpCacheService.updateWorkPackage(wp);
})
.catch(error => {
if (error.data instanceof ErrorResource) {
wpNotificationsService.showError(error.data, this.workPackage);
} else {
if (error instanceof ErrorResource) {
wpNotificationsService.showError(error, this.workPackage);
}
else {
wpNotificationsService.showGeneralError();
}
});
@ -95,8 +91,7 @@ export class WorkPackageParentRelationGroup extends WorkPackageRelationGroup {
protected init() {
if (this.workPackage.parent) {
this.workPackage.parent.$load()
.then(parent => this.relations.push(parent));
this.workPackage.parent.$load().then(parent => this.relations.push(parent));
}
}
}

Loading…
Cancel
Save