Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ahoy-jon
Copy link
Contributor

@ahoy-jon ahoy-jon commented Jun 1, 2020

Symmetrical to orDie and orDieWith:

ZIO.fail(new Exception("msg")).orDie.resurrect

@neko-kai
Copy link
Member

neko-kai commented Jun 1, 2020

resurrectWith is refineOrDie i think?

@ahoy-jon
Copy link
Contributor Author

ahoy-jon commented Jun 1, 2020

@neko-kai 🤔 refineOrDie is not managing errors from the sandbox. Are you sure?

final def refineOrDie[E1](pf: PartialFunction[E, E1])(implicit ev1: E <:< Throwable, ev2: CanFail[E]): ZIO[R, E1, A] =
    refineOrDieWith(pf)(ev1)

final def refineOrDieWith[E1](pf: PartialFunction[E, E1])(f: E => Throwable)(implicit ev: CanFail[E]): ZIO[R, E1, A] =
    self catchAll (err => (pf lift err).fold[ZIO[R, E1, A]](ZIO.die(f(err)))(ZIO.fail(_)))

@neko-kai
Copy link
Member

neko-kai commented Jun 1, 2020

@ahoy-jon Right, my mistake 😅

@ahoy-jon
Copy link
Contributor Author

ahoy-jon commented Jun 1, 2020

@neko-kai thanks for the review anyway.

Btw, I changed the function for resurrectWith to make it more useful (IMO).
The test looks cleaner, that's a good sign.

@ahoy-jon
Copy link
Contributor Author

ahoy-jon commented Jun 1, 2020

Oups, a timeout bug from CI.

Copy link
Member

@jdegoes jdegoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@jdegoes jdegoes merged commit 1f4eedc into zio:master Jun 2, 2020
@ahoy-jon ahoy-jon mentioned this pull request Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants