Global error handling
See original GitHub issueHi, In my application, as is quite common, I handle errors coming back from the server in the same global way, throughout the app. Right now, every time I make a mutation to the server, I need to include error handling code every time, which is just boilerplate overhead. In my specific case, I use react with redux, and dispatch an action on error to display a snackbar. So, every mutation has this same added code:
mutate(...).catch(err => {
const error = err.graphQLErrors[0].message
props.showUserFeedback(error)
})
where I need to connect the component to redux just for that action, and so forth.
I propose some kind of global error handling in the apollo client settings, maybe with a different way to handle each kind of error, and that could be overridden.
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:26 (4 by maintainers)
Top Results From Across the Web
Global Error Handling in ASP.NET Core Web API - Code Maze
NET Core. In this article, we are going to handle errors by using a try-catch block first and then rewrite our code by...
Read more >Global Error Handling in ASP.NET Web API 2 - Microsoft Learn
Global exception handling and logging should be services that can run during production and be plugged into existing monitoring solutions (for ...
Read more >NET 6.0 - Global Error Handler Tutorial with Example
The global error handler is used catch all errors and remove the need for duplicated error handling code throughout the .NET api.
Read more >Global Exception Handling in .NET 6 | Syncfusion Blogs
Global exception handling with custom middleware grants the developer much broader authority and enhances the procedure. It's a block of code ...
Read more >Global Exception Handler - UiPath Documentation Portal
The Global Exception Handler is a type of workflow designed to determine the project's behavior when encountering an execution error.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I did something along these lines:
Obviously showUserFeedback is implemented somewhere… Hope this helps!
@jazzdragon you’re not the only one to have missed that. The documentation could really use a “global error handling” section or something; currently the only way a user can find out how to handle errors globally in Apollo is to:
Far more likely they’ll discover the local error handling and think that’s all Apollo offers, because that’s all that’s highlighted in the documentation.