From 9736749a779661a95211a91200617a03a1b9a702 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 15 Aug 2021 15:03:44 +0200 Subject: Added a count query parameter to the log API endpoint --- packages/server/src/routes/api/v1/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'packages/server/src/routes/api/v1/index.ts') diff --git a/packages/server/src/routes/api/v1/index.ts b/packages/server/src/routes/api/v1/index.ts index fa7d8ab..fb9cd8a 100644 --- a/packages/server/src/routes/api/v1/index.ts +++ b/packages/server/src/routes/api/v1/index.ts @@ -9,6 +9,12 @@ import { ServerError } from "../../../git/error"; function setHandlers(fastify: FastifyInstance): void { fastify.setErrorHandler((err, req, reply) => { console.log(err); + + if(err.validation) { + reply.code(400).send({ error: `${err.validation[0].dataPath} ${err.validation[0].message}` }); + return; + } + reply.code(500).send({ error: "Internal server error!" }); }); fastify.setNotFoundHandler((req, reply) => { -- cgit v1.2.3-18-g5258