mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
throw 403 error instead of 422 and display toast message
This commit is contained in:
@@ -11,16 +11,19 @@ const makeFetch = (method, url, body) => {
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
console.log('200 error')
|
||||
return response.json();
|
||||
}
|
||||
|
||||
if (response.status === 422) {
|
||||
console.log('422 error')
|
||||
return response.json().then(response => {
|
||||
throw ValidationException(response)
|
||||
});
|
||||
}
|
||||
|
||||
if (response.status === 403) {
|
||||
console.log('403 error')
|
||||
throw AccessException(response);
|
||||
}
|
||||
|
||||
@@ -92,15 +95,8 @@ const ValidationException = (response) => {
|
||||
const AccessException = (response) => {
|
||||
const error = {};
|
||||
error.name = 'AccessException';
|
||||
error.violations = ['You are not allowed to perform this action'];
|
||||
|
||||
switch (response.url) {
|
||||
case 'http://localhost:8001/api/1.0/person/accompanying-course/5183/intensity.json':
|
||||
error.violations = ['Only the referrer is allowed to change the intensity of a parcours'];
|
||||
break;
|
||||
default:
|
||||
error.violations = ['You are not allowed to perform this action'];
|
||||
break;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user