Skip to content

Instantly share code, notes, and snippets.

@jasdev
Last active April 7, 2020 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasdev/0f5f36ae0cbea851eb4ac37e9635e30e to your computer and use it in GitHub Desktop.
Save jasdev/0f5f36ae0cbea851eb4ac37e9635e30e to your computer and use it in GitHub Desktop.
`setFailureType` setup with `Just`.
import Combine
/// (1) A sample error type we’ll try to promote `Never` to.
enum OurError: Error {
case anError
}
Just(6_174) /// (2) [`Just<Int>.Failure == Never`](https://developer.apple.com/documentation/combine/just/failure).
.mapError { /* `(Never) -> OurError` */ } /// (3) This is…awkward. `mapError` accepts an `(Failure) -> E`
/// closure for some new `Error`-conforming type, `E`. But, this block is never executed since,
/// well, there aren’t any `Never` instances to call it with.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment