Handles errors from an upstream publisher by replacing it with another publisher.
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- watchOS 6.0+
- Xcode 11.0+
A closure that accepts the upstream failure as input and returns a publisher to replace the upstream publisher.
A publisher that handles errors from an upstream publisher by replacing the failed publisher with another publisher.
catch(_:) to replace an error from an upstream publisher with a new publisher.
In the example below, the
catch(_:) operator handles the
Simple thrown by the upstream publisher by replacing the error with a
Just publisher. This continues the stream by publishing a single value and completing normally.