Generic Instance Method

mapError(_:)

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

Declaration

func mapError<E>(_ transform: @escaping (Self.Failure) -> E) -> Publishers.MapError<Self, 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.

See Also

Mapping Elements

func map<T>((Self.Output) -> T) -> Publishers.Map<Self, T>

Transforms all elements from the upstream publisher with a provided closure.

func tryMap<T>((Self.Output) -> T) -> Publishers.TryMap<Self, T>

Transforms all elements from the upstream publisher with a provided error-throwing closure.

func flatMap<T, P>(maxPublishers: Subscribers.Demand, (Self.Output) -> P) -> Publishers.FlatMap<P, Self>

Transforms all elements from an upstream publisher into a new or existing publisher.

func replaceNil<T>(with: T) -> Publishers.Map<Self, T>

Replaces nil elements in the stream with the provided element.

func scan<T>(T, (T, Self.Output) -> T) -> Publishers.Scan<Self, T>

Transforms elements from the upstream publisher by providing the current element to a closure along with the last value returned by the closure.

func tryScan<T>(T, (T, Self.Output) -> T) -> Publishers.TryScan<Self, T>

Transforms elements from the upstream publisher by providing the current element to an error-throwing closure along with the last value returned by the closure.

func setFailureType<E>(to: E.Type) -> Publishers.SetFailureType<Self, E>

Changes the failure type declared by the upstream publisher.