dry-monads icon indicating copy to clipboard operation
dry-monads copied to clipboard

Do::Halt - use Exception instead of StandardError

Open gogiel opened this issue 5 years ago • 2 comments

Do::Halt is a StandardError. Because of that rescue block can unexpectedly catch it in a wrapped method. This problem has been reported at https://github.com/dry-rb/dry-monads/issues/72

If Do::Halt was a direct Exception derivative it would be nearly invisible to end-user.

Both ActiveRecord and Sequel catch Exception. While this indeed is a breaking change it shouldn't affect majority of users.

In Discourse discussion we agreed that this breaking change will be included in some future major release.

gogiel avatar Jun 26 '19 23:06 gogiel

What about using throw/catch instead?

nixme avatar Sep 18 '19 23:09 nixme

@nixme using exceptions makes do notation transparent to transaction-like code (like one in AR and sequel), this is an important use case. We could have two versions of do notation with raise/rescue and throw/catch and let the user decide but that would be an overkill.

flash-gordon avatar Sep 23 '19 12:09 flash-gordon