Skip to content

Commit

Permalink
allow client side code to throw HttpError
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloSzx committed Aug 17, 2021
1 parent ee11111 commit 743d2a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from "./get-graphql-parameters";
export * from "./process-request";
export * from "./should-render-graphiql";
export * from "./types";
export * from "./errors";
18 changes: 11 additions & 7 deletions packages/core/src/process-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,17 @@ export const processRequest = async <TContext = {}, TRootValue = {}>(
}
}
} catch (executionError: any) {
throw new HttpError(
500,
"Unexpected error encountered while executing GraphQL request.",
{
graphqlErrors: [new GraphQLError(executionError.message)],
}
);
if (executionError instanceof HttpError) {
throw executionError;
} else {
throw new HttpError(
500,
"Unexpected error encountered while executing GraphQL request.",
{
graphqlErrors: [new GraphQLError(executionError.message)],
}
);
}
}
} catch (error: any) {
const payload = {
Expand Down

0 comments on commit 743d2a8

Please sign in to comment.