From 8e3406f8fc72f1f6a78c0540fc16b042d119a77c Mon Sep 17 00:00:00 2001 From: Florian BOUILLON Date: Thu, 29 Feb 2024 14:14:05 +0100 Subject: [PATCH] feat: Add more error loggin to catch this shitty error Signed-off-by: Florian BOUILLON --- server/src/index.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/server/src/index.ts b/server/src/index.ts index 35405ac53..bba142306 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -1,5 +1,5 @@ import Sentry from '@sentry/node' -import express from 'express' +import express, { NextFunction } from 'express' import jsonEndpoints from './V2/endpoints/jsonEndpoints' import graphql from './V2/graphql' import status from './status' @@ -86,6 +86,20 @@ if (sentryDSN) { server.use(Sentry.Handlers.errorHandler()) } +// error logging to the backend +server.use((err: Error, _1: any, _2: any, next: NextFunction) => { + // add a full line dash to not miss it + const columns = (process?.stdout?.columns ?? 32) - 7 + const dashes = ''.padEnd(columns / 2, '-') + + // colorize the lines to make sur to not miss it + console.error(`\x1b[91m${dashes} ERROR ${dashes}\x1b[0m`) + console.error(err) + console.error(`\x1b[91m${dashes} ERROR ${dashes}\x1b[0m`) + + next(err) +}) + // Start server server.listen(3000) console.log(`🚀 Server ready at localhost:3000`);