From 993032e5c01ed59f7f0cc3dff4bae900e815df75 Mon Sep 17 00:00:00 2001 From: gearnode Date: Sun, 23 Mar 2025 23:50:16 +0100 Subject: [PATCH] Add custom exception for internal server error Signed-off-by: gearnode --- apps/console/src/RelayEnvironment.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/console/src/RelayEnvironment.ts b/apps/console/src/RelayEnvironment.ts index 1995fe1bb..915b46ff3 100644 --- a/apps/console/src/RelayEnvironment.ts +++ b/apps/console/src/RelayEnvironment.ts @@ -15,6 +15,13 @@ export class UnAuthenticatedError extends Error { } } +export class InternalServerError extends Error { + constructor() { + super("INTERNAL_SERVER_ERROR"); + this.name = "InternalServerError"; + } +} + const hasUnauthenticatedError = (error: GraphQLError) => error.extensions?.code == "UNAUTHENTICATED"; @@ -75,6 +82,10 @@ const fetchRelay: FetchFunction = async ( requestInit ); + if (response.status === 500) { + throw new InternalServerError(); + } + const json = await response.json(); if (json.errors) {