X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Ferror.ts;h=34c87a26d8dc7522670c02b357c0d3a095d3c8de;hb=4ec52d04dcc5d664612331f8e08d7d90da990415;hp=e3eb1c8f54b8bc94d5943e692d9f9cfb503f980d;hpb=cf21b2cbef61929177b9c09b5e017c3b7eb8535d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/error.ts b/server/middlewares/error.ts index e3eb1c8f5..34c87a26d 100644 --- a/server/middlewares/error.ts +++ b/server/middlewares/error.ts @@ -1,6 +1,7 @@ -import * as express from 'express' +import express from 'express' import { ProblemDocument, ProblemDocumentExtension } from 'http-problem-details' -import { HttpStatusCode } from '@shared/core-utils' +import { logger } from '@server/helpers/logger' +import { HttpStatusCode } from '@shared/models' function apiFailMiddleware (req: express.Request, res: express.Response, next: express.NextFunction) { res.fail = options => { @@ -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()