mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-29 12:01:32 +02:00
Merge pull request #89 from overleaf/spd-error-logging-fix
Move error handler to be the last middleware
This commit is contained in:
@@ -16,7 +16,7 @@ const RequestLogger = require('./app/js/RequestLogger')
|
||||
|
||||
const app = express()
|
||||
|
||||
RequestLogger.attach(app)
|
||||
app.use(RequestLogger.middleware)
|
||||
|
||||
if (settings.sentry && settings.sentry.dsn) {
|
||||
logger.initializeErrorReporting(settings.sentry.dsn)
|
||||
@@ -140,6 +140,8 @@ app.get('/status', function(req, res) {
|
||||
|
||||
app.get('/health_check', healthCheckController.check)
|
||||
|
||||
app.use(RequestLogger.errorHandler)
|
||||
|
||||
const port = settings.internal.filestore.port || 3009
|
||||
const host = '0.0.0.0'
|
||||
|
||||
|
||||
@@ -15,13 +15,8 @@ class RequestLogger {
|
||||
this._logMessage = message
|
||||
}
|
||||
|
||||
static attach(app) {
|
||||
app.use(RequestLogger.middleware)
|
||||
app.use(RequestLogger.errorHandler)
|
||||
}
|
||||
|
||||
static errorHandler(err, req, res, next) {
|
||||
req.requestLogger._logInfo.error = err
|
||||
req.requestLogger.addFields({ error: err })
|
||||
res
|
||||
.send(err.message)
|
||||
.status(500)
|
||||
|
||||
Reference in New Issue
Block a user