vuejs: better violations message in 422 error handling

This commit is contained in:
nobohan 2022-01-11 09:34:15 +01:00
parent 378f3a16fc
commit 40e4bf953f
2 changed files with 5 additions and 4 deletions

View File

@ -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;
}

View File

@ -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'});