Generic Instance Method


Converts any failure from the upstream publisher into a new error.


func mapError<E>(_ transform: @escaping (Upstream.Failure) -> E) -> Publishers.MapError<Publishers.Share<Upstream>, E> where E : Error



A closure that takes the upstream failure as a parameter and returns a new error for the publisher to terminate with.

Return Value

A publisher that replaces any upstream failure with a new error produced by the transform closure.


Until the upstream publisher finishes normally or fails with an error, the returned publisher republishes all the elements it receives.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software