From c5c0ca3020e7a9a5b83a7ce59eefc91e6abb1e62 Mon Sep 17 00:00:00 2001 From: bludnic Date: Thu, 29 Aug 2024 07:10:31 +0100 Subject: [PATCH] fix(tRPC): throw an error when creating a GridBot with no grid lines --- .../src/routers/private/grid-bot/create-bot/handler.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/trpc/src/routers/private/grid-bot/create-bot/handler.ts b/packages/trpc/src/routers/private/grid-bot/create-bot/handler.ts index 833529c7..71ce106e 100644 --- a/packages/trpc/src/routers/private/grid-bot/create-bot/handler.ts +++ b/packages/trpc/src/routers/private/grid-bot/create-bot/handler.ts @@ -38,6 +38,13 @@ export async function createGridBot({ ctx, input }: Options) { }); } + if (data.settings.gridLines.length === 0) { + throw new TRPCError({ + message: "The bot has no configured grid lines. Please set at least one grid line", + code: "PARSE_ERROR", + }); + } + const bot = await xprisma.bot.grid.create({ data: { ...data,