Generic Structure

Publishers.TryCatch

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

Declaration

struct TryCatch<Upstream, NewPublisher> where Upstream : Publisher, NewPublisher : Publisher, Upstream.Output == NewPublisher.Output

Overview

Because this publisher’s handler can throw an error, Publishers.TryCatch defines its Failure type as Error. This is different from Publishers.Catch, which gets its failure type from the replacement publisher.

Topics

Initializers

init(upstream: Upstream, handler: (Upstream.Failure) -> NewPublisher)

Creates a publisher that handles errors from an upstream publisher by replacing the failed publisher with another publisher or by throwing an error.

Instance Properties

let handler: (Upstream.Failure) -> NewPublisher

A closure that accepts the upstream failure as input and either returns a publisher to replace the upstream publisher or throws an error.

let upstream: Upstream

The publisher that this publisher receives elements from.

Instance Methods

Relationships

Conforms To

See Also

Handling Errors

struct Publishers.AssertNoFailure

A publisher that raises a fatal error upon receiving any failure, and otherwise republishes all received input.

struct Publishers.Catch

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

struct Publishers.Retry

A publisher that attempts to recreate its subscription to a failed upstream publisher.