Add custom exception for internal server error
Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user