Add custom exception for internal server error

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-03-23 23:50:16 +01:00
parent b8ddb110b3
commit 993032e5c0

View File

@@ -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) {