From 40e4bf953fa8e9a04a34e0330562bd25324c5589 Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 11 Jan 2022 09:34:15 +0100 Subject: [PATCH] vuejs: better violations message in 422 error handling --- .../ChillMainBundle/Resources/public/lib/api/apiMethods.js | 5 +++-- .../Resources/public/vuejs/_components/AddPersons.vue | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.js b/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.js index 9697a5d68..5ad119858 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.js +++ b/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.js @@ -85,8 +85,9 @@ const fetchScopes = () => { const ValidationException = (response) => { const error = {}; error.name = 'ValidationException'; - error.violations = response.violations.map((violation) => `${violation.title}`); - error.propertyPaths = response.violations.map((violation) => `${violation.propertyPath}`); + error.violations = response.violations.map((violation) => `${violation.title}: ${violation.propertyPath}`); + error.titles = response.violations.map((violation) => violation.title); + error.propertyPaths = response.violations.map((violation) => violation.propertyPath); return error; } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue index d5025c6b1..0aa1bb1d7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue @@ -275,8 +275,8 @@ export default { .catch((error) => { //commit('catchError', error); if (error.name === 'ValidationException') { - for (let e of error.propertyPaths) { - this.$toast.open({message: `${e}` }); //TODO better exploit violations messages + for (let v of error.violations) { + this.$toast.open({message: v }); } } else { this.$toast.open({message: 'An error occurred'});