Generic Instance Method

# catch(_:)

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

## Parameters

`handler`

A closure that accepts the upstream failure as input and returns a publisher to replace the upstream publisher.

## Return Value

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

## Discussion

The following example replaces any error from the upstream publisher and replaces the upstream with a `Just` publisher. This continues the stream by publishing a single value and completing normally.

Backpressure note: This publisher passes through `request` and `cancel` to the upstream. After receiving an error, the publisher sends any unfulfilled demand to the new `Publisher`.

### Handling Errors

`func assertNoFailure(String, file: StaticString, line: UInt) -> Publishers.AssertNoFailure<Self>`

Raises a fatal error when its upstream publisher fails, and otherwise republishes all received input.

`func tryCatch<P>((Self.Failure) -> P) -> Publishers.TryCatch<Self, P>`

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

`func retry(Int) -> Publishers.Retry<Self>`

Attempts to recreate a failed subscription with the upstream publisher using a specified number of attempts to establish the connection.