mrpmorris / Fluxor

Fluxor is a zero boilerplate Flux/Redux library for Microsoft .NET and Blazor.
MIT License
1.22k stars 139 forks source link

Handle exceptions during execution of effects #417

Closed Code-Chops closed 1 year ago

Code-Chops commented 1 year ago

Is there a way to handle exceptions during handling of effects?

My effect handlers communicate with an API and in case something goes wrong it should be gracefully handled.

I know it is possible to place a try-catch in every effect handler and dispatch a fail action when an error occurs, but this has to be implemented all the time and is therefore not preferred.

mrpmorris commented 1 year ago

Each effect should handle its own exceptions, because it is in the best position to know what they are and what should be done about each kind.

The StoreInitializer component does have an event for unhandled exceptions, but that's not the route I would advise you go down.