Generic Instance Method

mapError(_:)

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

Declaration

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

Parameters

transform

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.

Discussion

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