From e50db0208a968013c272c2e38e733bc11d1c6140 Mon Sep 17 00:00:00 2001 From: Richard Date: Thu, 31 Jul 2014 15:15:30 +0200 Subject: [PATCH] Use full error messages for relations validation. --- .../javascripts/angular/helpers/components/api-helper.js | 9 +++++---- lib/api/errors/validation.rb | 2 +- lib/api/v3/relations/relations_api.rb | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/angular/helpers/components/api-helper.js b/app/assets/javascripts/angular/helpers/components/api-helper.js index 1faef73d3d..9c110c5e8e 100644 --- a/app/assets/javascripts/angular/helpers/components/api-helper.js +++ b/app/assets/javascripts/angular/helpers/components/api-helper.js @@ -38,11 +38,12 @@ angular.module('openproject.workPackages.helpers') }, getErrorMessage: function(error) { - var response = JSON.parse(error.responseText); if(error.status == 422) { - return response.description + response.errors.map(function(error) { - return " \"" + error.key + "\"" + " " + error.messages[0]; - }).join('. '); + var response = JSON.parse(error.responseText); + return response.errors.join('. '); + } + if(error.status == 500) { + return error.statusText; } }, diff --git a/lib/api/errors/validation.rb b/lib/api/errors/validation.rb index e8a38b6f3b..b175ee1801 100644 --- a/lib/api/errors/validation.rb +++ b/lib/api/errors/validation.rb @@ -41,7 +41,7 @@ module API end def errors - @obj.errors.messages.map{ |m| { key: m[0], messages: m[1] }} + @obj.errors.full_messages end def to_json diff --git a/lib/api/v3/relations/relations_api.rb b/lib/api/v3/relations/relations_api.rb index 3c40a7f015..c708b0057d 100644 --- a/lib/api/v3/relations/relations_api.rb +++ b/lib/api/v3/relations/relations_api.rb @@ -25,7 +25,7 @@ module API relation.save! representer.to_json else - raise ::API::Errors::Validation.new(relation) + fail Errors::Validation.new(relation) end end