From f2b57a358921c076088d17a994ed2daf44ec9db7 Mon Sep 17 00:00:00 2001 From: Matti Nannt Date: Sat, 14 Oct 2023 18:38:49 +0200 Subject: [PATCH] chore: improve logging in survey service (#1156) --- packages/lib/survey/service.ts | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/packages/lib/survey/service.ts b/packages/lib/survey/service.ts index 96e303675b..64bcb43e53 100644 --- a/packages/lib/survey/service.ts +++ b/packages/lib/survey/service.ts @@ -107,10 +107,8 @@ export const getSurveyWithAnalytics = async (surveyId: string): Promise => { select: selectSurvey, }); } catch (error) { - if (error instanceof Error) { - console.error(error.message); - } if (error instanceof Prisma.PrismaClientKnownRequestError) { + console.error(error.message); throw new DatabaseError("Database operation failed"); } @@ -322,10 +318,8 @@ export const getSurveys = async (environmentId: string): Promise => { select: selectSurvey, }); } catch (error) { - if (error instanceof Error) { - console.error(error.message); - } if (error instanceof Prisma.PrismaClientKnownRequestError) { + console.error(error.message); throw new DatabaseError("Database operation failed"); } @@ -345,9 +339,6 @@ export const getSurveys = async (environmentId: string): Promise => { } return surveys; } catch (error) { - if (error instanceof Error) { - console.error(error.message); - } if (error instanceof z.ZodError) { console.error(JSON.stringify(error.errors, null, 2)); // log the detailed error information } @@ -383,10 +374,8 @@ export const getSurveysWithAnalytics = async (environmentId: string): Promise { return modifiedSurvey; } catch (error) { - if (error instanceof Error) { - console.error(error.message); - } if (error instanceof Prisma.PrismaClientKnownRequestError) { + console.error(error.message); throw new DatabaseError("Database operation failed"); }