Generic Instance Method

tryCatch(_:)

Handles errors from an upstream publisher by replacing it with another publisher or an error.

Declaration

func tryCatch<P>(_ handler: @escaping (Upstream.Failure) throws -> P) -> Publishers.TryCatch<Publishers.Map<Upstream, Output>, P> where P : Publisher, Self.Output == P.Output

Parameters

handler

A closure that accepts the upstream failure as input and returns a publisher to replace the upstream publisher. If this closure throws an error, the publisher terminates with the thrown error.

Return Value

A publisher that handles errors from an upstream publisher by replacing the failed publisher with another publisher, or an error.