Implement error handling according to the specs

pull/2081/head
Hagen Schink 10 years ago
parent 1cd3cab13d
commit 8629bd9ecc
  1. 23
      app/assets/javascripts/angular/work_packages/helpers/api-helper.js

@ -38,15 +38,30 @@ angular.module('openproject.workPackages.helpers')
},
getErrorMessage: function(error) {
if(error.status == 422) {
var response = JSON.parse(error.responseText);
return response.errors.join('. ');
}
if(error.status == 500) {
return error.statusText;
} else {
var response = JSON.parse(error.responseText);
var messages = [];
var message;
if (ApiHelper.isMultiErrorMessage(response)) {
angular.forEach(response._embedded.errors, function(error) {
this.push(error.message);
}, messages);
} else {
messages.push(response.message);
}
message = messages.join('. ') + '.';
return message;
}
},
isMultiErrorMessage: function(error) {
return error.errorIdentifier == 'urn:openproject-org:api:v3:errors:MultipleErrors';
}
};
return ApiHelper;

Loading…
Cancel
Save