1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-04-22 19:02:10 +00:00

feat: Add more error loggin to catch this shitty error

Signed-off-by: Florian BOUILLON <f.bouillon@aptatio.com>
This commit is contained in:
Florian Bouillon 2024-02-29 14:14:05 +01:00
parent e6a8c1dd71
commit 8e3406f8fc

View File

@ -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`);