typelevel / mouse

A small companion to cats
MIT License
363 stars 66 forks source link

Add getOrRethrow into feither #459

Closed geirolz closed 8 months ago

geirolz commented 9 months ago

Hi guys! This PR adds one useful method to re-throw an exception wrapped as Left into an F where a MonadThrow is available.

I'm not sure about the naming, I'd like to continue using "raise" instead of "throw" but I named it "rethrow" because it's also present into EitherT. Other alternatives that came to mind are:

Example

val result: Try[Int] = Try(new RuntimeException("BOOM!").asLeft[Int]).getOrRethrow