X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Fmiddlewares%2Ferror.ts;h=34c87a26d8dc7522670c02b357c0d3a095d3c8de;hb=c55e3d7227fe1453869e309025996b9d75256d5d;hp=6c52ce7bd98f7fa98e7d551e07249991d6248002;hpb=41fb13c330de629df2d23379209e79c7af0f2e9a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/error.ts b/server/middlewares/error.ts index 6c52ce7bd..34c87a26d 100644 --- a/server/middlewares/error.ts +++ b/server/middlewares/error.ts @@ -1,5 +1,6 @@ import express from 'express' import { ProblemDocument, ProblemDocumentExtension } from 'http-problem-details' +import { logger } from '@server/helpers/logger' import { HttpStatusCode } from '@shared/models' function apiFailMiddleware (req: express.Request, res: express.Response, next: express.NextFunction) { @@ -18,7 +19,8 @@ function apiFailMiddleware (req: express.Request, res: express.Response, next: e res.status(status) res.setHeader('Content-Type', 'application/problem+json') - res.json(new ProblemDocument({ + + const json = new ProblemDocument({ status, title, instance, @@ -28,7 +30,11 @@ function apiFailMiddleware (req: express.Request, res: express.Response, next: e type: type ? `https://docs.joinpeertube.org/api-rest-reference.html#section/Errors/${type}` : undefined - }, extension)) + }, extension) + + logger.debug('Bad HTTP request.', { json }) + + res.json(json) } if (next) next()