From 0782f49725e29ab939996a7572b006870c07b88d Mon Sep 17 00:00:00 2001 From: Florian Sylvain Date: Wed, 11 Jan 2023 11:13:35 +0100 Subject: [PATCH] Catch sort query error --- routes/shows.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/routes/shows.js b/routes/shows.js index 6fa25ec..77ad238 100644 --- a/routes/shows.js +++ b/routes/shows.js @@ -40,6 +40,11 @@ showsRouter.get('/', function (req, res, next) { prisma.serie.findMany(filter) .then(shows => res.send({ shows })) + .catch(error => { + if (error instanceof Prisma.PrismaClientValidationError) { + next(createHttpError(400, 'Incorrect field in sort query.')) + } + }) }) showsRouter.get('/:id', function (req, res, next) {