Closed shivamkj closed 2 weeks ago
Can you please file an issue with a minimal reproduction sample that illustrates the issue before opening a PR? That way I can better understand the issue and we can align on a solution before writing any code. Thanks!
Status
READY
Breaking Changes
NO
Description
By default, bloc will rethrow any error caught during the event, which can't be configured. Now suppose, you have multiple events doing similar things (like making an API request), so you wrote a reusable error handler that can handle errors for all these events. But now you have to to wrap each of these event handlers in try catch and call the error handler in catch block of each event handler. If we make rethrow configurable, we can just override the
onError
of the bloc and handle error from just single place. Note: You can still handle error inonError
without adding try catch but Dart will complain about an uncaught error for every error throw, even though you have handled it inonError
. This PR tries to make that rethrow optional with a condition that end developers can configure as per their needs. By default condition is true, so it will work as it works now.Type of Change