Skip to content

Commit

Permalink
feat(error.ts): add new error handling functions for GraphQL errors
Browse files Browse the repository at this point in the history
- Implement throwGraphQLError function to throw a new GraphQLError with custom message, code, and status
- Implement throwActionStateError function to throw a specific GraphQLError when an action state is not found
  • Loading branch information
MartinMinkov committed Feb 23, 2024
1 parent aabb2ea commit e33c2e6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/errors/error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { GraphQLError } from 'graphql';

export { throwGraphQLError, throwActionStateError };

function throwGraphQLError(message: string, code?: string, status?: number) {
throw new GraphQLError(message, {
extensions: {
code,
status,
},
});
}

function throwActionStateError(message: string) {
throwGraphQLError(message, 'ACTION_STATE_NOT_FOUND', 400);
}

0 comments on commit e33c2e6

Please sign in to comment.