diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js index f595daa34..5533bd6ff 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js @@ -20,7 +20,9 @@ const makeFetch = (method, url, body) => { } if (response.status === 422) { - return response.json(); + return response.json().then(violations => { + throw ValidationException(violations) + }); } throw { @@ -33,13 +35,22 @@ const makeFetch = (method, url, body) => { }); } +/** + * @param violations + * @constructor + */ +const ValidationException = (violations) => { + this.violations = violations + this.name = 'ValidationException' +} + /** * @function getFetch * @param url * @returns {Promise} */ const getFetch = (url) => { - return makeFetch('GET', url, null); + return makeFetch('GET', url, null) } /** @@ -49,7 +60,7 @@ const getFetch = (url) => { * @returns {Promise} */ const postFetch = (url, body) => { - return makeFetch('POST', url, body); + return makeFetch('POST', url, body) } /** @@ -59,7 +70,7 @@ const postFetch = (url, body) => { * @returns {Promise} */ const patchFetch = (url, body) => { - return makeFetch('PATCH', url, body); + return makeFetch('PATCH', url, body) }