Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client: avoid throwing outside of effect system #2502

Merged
merged 2 commits into from Apr 16, 2019

Conversation

Projects
None yet
3 participants
@yoohaemin
Copy link
Contributor

commented Apr 11, 2019

A json decoding failure was causing fiber death when used with ZIO.

@rossabaker

This comment has been minimized.

Copy link
Member

commented Apr 11, 2019

There are a couple more of these in that file. Throwing in a bracket is not guaranteed by law to raise the error into F, so I agree we should change these. Would you be interested in getting the rest? It should just be a search and replace.

@yoohaemin

This comment has been minimized.

Copy link
Contributor Author

commented Apr 11, 2019

Sure, will do

@rossabaker

This comment has been minimized.

Copy link
Member

commented Apr 11, 2019

Note that there are a bunch in core, but those are Eithers, in methods named unsafe. Anywhere we're doing this outside a test or a convenience method marked as unsafe is bad.

@yoohaemin

This comment has been minimized.

Copy link
Contributor Author

commented Apr 14, 2019

I wonder what the difference is between using .rethrowT and .value.flatMap(_.fold(F.raiseError(_), F.pure(_))) from the other PR. Would there be a meaningful difference?

@rossabaker

This comment has been minimized.

Copy link
Member

commented Apr 14, 2019

It's usually not meaningful, but yours has a slight chance at being better:

  • .rethrowT is MonadError[F, Throwable].rethrow(value).
  • MonadError[F, Throwable].rethrow defaults to flatMap(fa)(_.fold(raiseError, pure)), but maybe some F out there somewhere optimized it.

typelevel/cats#2237 will give us a better way still.

@rossabaker rossabaker merged commit 417a168 into http4s:master Apr 16, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.