Skip to content

Commit

Permalink
fix: catch throw on dossier-apprenant (#3862)
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Gaucher <[email protected]>
  • Loading branch information
Pomarom and Pomarom authored Oct 17, 2024
1 parent c81a661 commit bc2208b
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions server/src/http/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,21 +403,24 @@ function setupRoutes(app: Application) {
["/api/v3/dossiers-apprenants"],
requireBearerAuthentication(),
async (req, res, next) => {
const organisme = await getOrganismeByAPIKey(res.locals.token, req.query);
try {
const organisme = await getOrganismeByAPIKey(res.locals.token, req.query);

(req.user as any) = {
source: SOURCE_APPRENANT.ERP,
source_organisme_id: organisme._id.toString(),
};

Sentry.setUser({
segment: "bearer",
ip_address: req.ip,
id: `organisme-${organisme._id.toString()}`,
username: `organisme: ${organisme.siret} / ${organisme.uai}`,
});
(req.user as any) = {
source: SOURCE_APPRENANT.ERP,
source_organisme_id: organisme._id.toString(),
};

next();
Sentry.setUser({
segment: "bearer",
ip_address: req.ip,
id: `organisme-${organisme._id.toString()}`,
username: `organisme: ${organisme.siret} / ${organisme.uai}`,
});
next();
} catch (err) {
next(err);
}
},
dossierApprenantRouter()
);
Expand Down

0 comments on commit bc2208b

Please sign in to comment.