graphql-java-kickstart / graphql-spring-boot

GraphQL and GraphiQL Spring Framework Boot Starters - Forked from oembedler/graphql-spring-boot due to inactivity.
https://www.graphql-java-kickstart.com/spring-boot/
MIT License
1.5k stars 325 forks source link

Support NullPointerException in ErrorHandler #896

Open gschei opened 2 years ago

gschei commented 2 years ago

Currently if a resolver throws a NullPointerException it cannot be handled by the ErrorHandler, because GraphqlErrorBuilder has a assertNotNull on the message and NullPointerException does not return a Message.

Assert.assertNotNull(this.message, () -> { return "You must provide error message"; });

I would suggest to enhance the GraphQLErrorFromExceptionHandler to set the Message alternatively with eg. the className. Then a NullPointerException would be handled gracefully and remaining data would be returned.