8000 Add refineOrDie and refineOrDieWith to ZSink by adrianfilip · Pull Request #7165 · zio/zio · GitHub
[go: up one dir, main page]

Skip to content

Add refineOrDie and refineOrDieWith to ZSink - #7165

Merged
adamgfraser merged 6 commits into
zio:series/2.xfrom
adrianfilip:Add_refineOrDie_and_refineOrDieWith_to_ZSink
Aug 3, 2022
Merged

adamgfraser merged 6 commits into
zio:series/2.xfrom
adrianfilip:Add_refineOrDie_and_refineOrDieWith_to_ZSink

Conversation

@adrianfilip
Copy link
Copy Markdown
Contributor

No description provided.

@adrianfilip
adrianfilip requested a review from iravid as a code owner August 2, 2022 22:37
@adamgfraser adamgfraser left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good. Left a couple of comments below.

)(f: E => Throwable)(implicit ev: CanFail[E], trace: Trace): ZSink[R, E1, In, L, Z] =
new ZSink(
channel.catchAll(e =>
if (pf.isDefinedAt(e))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This implementation currently requires potentially evaluating the partialFunction twice (once in isDefinedAt and a second time in apply). We should use another operator here like applyOrElse to avoid this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated here and also for ZStream


def refineOrDie[E1](
pf: PartialFunction[E, E1]
)(implicit ev1: E <:< Throwable, ev2: CanFail[E], trace: Trace): ZSink[R, E1, In, L, Z] =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should use isSubtypeOfError here for improved error messages.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated here and also for ZStream

def refineOrDie[E1](
pf: PartialFunction[E, E1]
)(implicit ev1: E <:< Throwable, ev2: CanFail[E], trace: Trace): ZStream[R, E1, A] =
)(implicit ev1: E IsSubtypeOfError Throwable, ev2: CanFail[E], trace: Trace): ZStream[R, E1, A] =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change is not going to be binary compatible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@adamgfraser
adamgfraser merged commit 3ba4215 into zio:series/2.x Aug 3, 2022
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.

2 participants

0