---
title: Publishers.TryCatch
framework: combine
role: symbol
role_heading: Structure
path: combine/publishers/trycatch
---

# 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

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

## Overview

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

### Creating a try-catch publisher

- [init(upstream:handler:)](combine/publishers/trycatch/init(upstream:handler:).md)

### Declaring supporting types

- [Publishers.TryCatch.Output](combine/publishers/trycatch/output.md)
- [Publishers.TryCatch.Failure](combine/publishers/trycatch/failure.md)

### Inspecting publisher properties

- [upstream](combine/publishers/trycatch/upstream.md)
- [handler](combine/publishers/trycatch/handler.md)

## Relationships

### Conforms To

- [Publisher](combine/publisher.md)

## See Also

### Handling errors

- [Publishers.AssertNoFailure](combine/publishers/assertnofailure.md)
- [Publishers.Catch](combine/publishers/catch.md)
- [Publishers.Retry](combine/publishers/retry.md)
