sideeffect-io / AsyncExtensions

AsyncExtensions aims to mimic Swift Combine operators for async sequences.
MIT License
334 stars 26 forks source link

opeators: add a MapError opeator #17

Open JCSooHwanCho opened 2 years ago

JCSooHwanCho commented 2 years ago

Description

This PR adds MapError Operator, which is transforms error upstream emits

Checklist

twittemb commented 2 years ago

Hi @JCSooHwanCho

Thanks for this PR.

Mmmmh, I'm not sure if this is useful to be able to map the error since an AsyncSequence, unlike a Combine publisher, is not parametrised by a Failure type.

In the end we still have to handle all kinds of Errors in the catch section. The mapError does not bring type safety here.

Do you see a big advantage to that ?

JCSooHwanCho commented 2 years ago

@twittemb I needed some functionality that catch some error and change it to another Error. so first I thought was mapError operator in Combine, implement and use it. but by your comment, catch operator in RxSwift is rather nicer than mapError with AsyncSequence case.

twittemb commented 2 years ago

@JCSooHwanCho I have introduced a .mapToResult operator (main branch), it might be more versatile