Skip to content

Commit

Permalink
🔊 Ajout de logs en cas d'erreur dans la page projet (#2211)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjlevesque authored and HubM committed Sep 20, 2024
1 parent 81c3047 commit c935af9
Showing 1 changed file with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { Raccordement } from '@potentiel-domain/reseau';
import { AchèvementRéelDTO } from '../../modules/frise';
import { Option } from '@potentiel-libraries/monads';
import { User } from '../../entities';
import { logger } from '../../core/utils';
const schema = yup.object({
params: yup.object({ projectId: yup.string().required() }),
});
Expand Down Expand Up @@ -60,8 +61,14 @@ v1Router.get(
safeAsyncHandler(
{
schema,
onError: ({ request, response }) =>
notFoundResponse({ request, response, ressourceTitle: 'Projet' }),
onError: ({ request, response, error }) => {
logger.warning(`Error in project details handler`, {
errorName: error?.name,
errorMessage: error?.message,
errorStackTrace: error?.stack,
});
return notFoundResponse({ request, response, ressourceTitle: 'Projet' });
},
},
async (request, response) => {
const { user } = request;
Expand Down Expand Up @@ -98,6 +105,11 @@ v1Router.get(
const rawProjet = await getProjectDataForProjectPage({ projectId, user });

if (rawProjet.isErr()) {
logger.warning(`Error in getProjectDataForProjectPage`, {
errorName: rawProjet.error?.name,
errorMessage: rawProjet.error?.message,
errorStackTrace: rawProjet.error?.stack,
});
return notFoundResponse({ request, response, ressourceTitle: 'Projet' });
}

Expand Down Expand Up @@ -126,6 +138,11 @@ v1Router.get(
const rawProjectEventList = await getProjectEvents({ projectId: projet.id, user });

if (rawProjectEventList.isErr()) {
logger.warning(`Error fetching project events`, {
errorName: rawProjectEventList.error?.name,
errorMessage: rawProjectEventList.error?.message,
errorStackTrace: rawProjectEventList.error?.stack,
});
return notFoundResponse({ request, response, ressourceTitle: 'Projet' });
}

Expand Down Expand Up @@ -253,7 +270,7 @@ const getAlertesRaccordement = async ({
data: { identifiantProjetValue: identifiantProjet.formatter() },
});

if(Option.isSome(dossiersRaccordement)) {
if (Option.isSome(dossiersRaccordement)) {
if (
CDC2022Choisi &&
dossiersRaccordement.dossiers[0].référence.estÉgaleÀ(
Expand Down

0 comments on commit c935af9

Please sign in to comment.