mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-30 00:13:21 +00:00
refactor: gestion des erreurs
This commit is contained in:
@ -8,13 +8,16 @@ import {
|
||||
BE_AUTH_NEW_PASSWORD_URL,
|
||||
FE_USERS_LOGIN_URL,
|
||||
} from '@/utils/Url';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
|
||||
const requestResponseHandler = async (response) => {
|
||||
const body = await response.json();
|
||||
if (response.ok) {
|
||||
return body;
|
||||
}
|
||||
const error = new Error('Form submission error');
|
||||
|
||||
const error = new Error(body?.errorMessage || "Une erreur est survenue");
|
||||
error.details = body;
|
||||
throw error;
|
||||
};
|
||||
|
||||
@ -9,7 +9,7 @@ const requestResponseHandler = async (response) => {
|
||||
return body;
|
||||
}
|
||||
// Throw an error with the JSON body containing the form errors
|
||||
const error = new Error('Form submission error');
|
||||
const error = new Error(body?.errorMessage || "Une erreur est survenue");
|
||||
error.details = body;
|
||||
throw error;
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ const requestResponseHandler = async (response) => {
|
||||
return body;
|
||||
}
|
||||
// Throw an error with the JSON body containing the form errors
|
||||
const error = new Error('Form submission error');
|
||||
const error = new Error(body?.errorMessage || "Une erreur est survenue");
|
||||
error.details = body;
|
||||
throw error;
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ const requestResponseHandler = async (response) => {
|
||||
return body;
|
||||
}
|
||||
// Throw an error with the JSON body containing the form errors
|
||||
const error = new Error('Form submission error');
|
||||
const error = new Error(body?.errorMessage || "Une erreur est survenue");
|
||||
error.details = body;
|
||||
throw error;
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ const requestResponseHandler = async (response) => {
|
||||
return body;
|
||||
}
|
||||
// Throw an error with the JSON body containing the form errors
|
||||
const error = new Error('Form submission error');
|
||||
const error = new Error(body?.errorMessage || "Une erreur est survenue");
|
||||
error.details = body;
|
||||
throw error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user