From fe25985eec2d1404446da62b2f02456b0f89a0fb Mon Sep 17 00:00:00 2001 From: Valtteri Kantanen Date: Wed, 6 Nov 2024 15:58:29 +0200 Subject: [PATCH] [Class statistics] Capture the full stack trace of errors instead of creating a new one --- services/backend/src/routes/population.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/services/backend/src/routes/population.ts b/services/backend/src/routes/population.ts index b2848ed6dc..28a9c520fb 100644 --- a/services/backend/src/routes/population.ts +++ b/services/backend/src/routes/population.ts @@ -118,8 +118,10 @@ router.post('/v2/populationstatistics/courses', async (req: PostPopulationStatis try { const result = await bottlenecksOf(query, null, encrypted) return res.json(result) - } catch (error: any) { - Sentry.captureException(new Error(error.message)) + } catch (error: unknown) { + if (error instanceof Error) { + Sentry.captureException(error) + } return res.status(400).end() } }) @@ -156,8 +158,10 @@ router.post( studentNumberList ) return res.json(result) - } catch (error: any) { - Sentry.captureException(new Error(error.message)) + } catch (error: unknown) { + if (error instanceof Error) { + Sentry.captureException(error) + } return res.status(400).end() } } @@ -200,8 +204,10 @@ router.post( studentNumbers ) return res.json(result) - } catch (error: any) { - Sentry.captureException(new Error(error.message)) + } catch (error: unknown) { + if (error instanceof Error) { + Sentry.captureException(error) + } return res.status(400).end() } }