diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/server/lib/object-storage/proxy.ts | 2 | ||||
-rw-r--r-- | server/server/middlewares/error.ts | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/server/server/lib/object-storage/proxy.ts b/server/server/lib/object-storage/proxy.ts index bef899fed..af37029f8 100644 --- a/server/server/lib/object-storage/proxy.ts +++ b/server/server/lib/object-storage/proxy.ts | |||
@@ -83,6 +83,8 @@ function handleObjectStorageFailure (res: express.Response, err: Error) { | |||
83 | return res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 83 | return res.sendStatus(HttpStatusCode.NOT_FOUND_404) |
84 | } | 84 | } |
85 | 85 | ||
86 | logger.error('Object storage failure', { err }) | ||
87 | |||
86 | return res.fail({ | 88 | return res.fail({ |
87 | status: HttpStatusCode.INTERNAL_SERVER_ERROR_500, | 89 | status: HttpStatusCode.INTERNAL_SERVER_ERROR_500, |
88 | message: err.message, | 90 | message: err.message, |
diff --git a/server/server/middlewares/error.ts b/server/server/middlewares/error.ts index 706009795..51012af07 100644 --- a/server/server/middlewares/error.ts +++ b/server/server/middlewares/error.ts | |||
@@ -17,11 +17,6 @@ function apiFailMiddleware (req: express.Request, res: express.Response, next: e | |||
17 | error: message | 17 | error: message |
18 | }) | 18 | }) |
19 | 19 | ||
20 | res.status(status) | ||
21 | |||
22 | if (!res.headersSent) { | ||
23 | res.setHeader('Content-Type', 'application/problem+json') | ||
24 | } | ||
25 | 20 | ||
26 | const json = new ProblemDocument({ | 21 | const json = new ProblemDocument({ |
27 | status, | 22 | status, |
@@ -37,6 +32,12 @@ function apiFailMiddleware (req: express.Request, res: express.Response, next: e | |||
37 | 32 | ||
38 | logger.debug('Bad HTTP request.', { json, tags }) | 33 | logger.debug('Bad HTTP request.', { json, tags }) |
39 | 34 | ||
35 | res.status(status) | ||
36 | |||
37 | // Cannot display a proper error to the client since headers are already sent | ||
38 | if (res.headersSent) return | ||
39 | |||
40 | res.setHeader('Content-Type', 'application/problem+json') | ||
40 | res.json(json) | 41 | res.json(json) |
41 | } | 42 | } |
42 | 43 | ||