mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Move error handler to be the last middleware
This commit is contained in:
parent
2f67ade3ec
commit
e4926e09a7
2 changed files with 4 additions and 7 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue