Skip to content

Commit 204b6fe

Browse files
authored
Merge branch 'develop' into fix-and-migrate-version-url-parser
2 parents 221eddd + d78c8af commit 204b6fe

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

server/server.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,20 @@ app.get('*', async (req, res) => {
195195
res.type('txt').send('Not found.');
196196
});
197197

198+
// Global error handler for unhandled errors
199+
app.use((error, req, res, next) => {
200+
console.error('Unhandled error:', error);
201+
202+
if (res.headersSent) {
203+
return next(error);
204+
}
205+
206+
const statusCode = error.status || 500;
207+
return res.status(statusCode).json({
208+
error: 'Internal server error'
209+
});
210+
});
211+
198212
// start app
199213
app.listen(process.env.PORT, (error) => {
200214
if (!error) {

0 commit comments

Comments
 (0)