<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Combine",
  "identifier" : "/documentation/Combine/Publishers/MapError",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine10PublishersO8MapErrorV"
  },
  "title" : "Publishers.MapError"
}
-->

# Publishers.MapError

A publisher that converts any failure from the upstream publisher into a new error.

```
struct MapError<Upstream, Failure> where Upstream : Publisher, Failure : Error
```

## Topics

### Creating an error-mapping publisher

[`init(upstream:_:)`](/documentation/Combine/Publishers/MapError/init(upstream:_:))

[`init(upstream:transform:)`](/documentation/Combine/Publishers/MapError/init(upstream:transform:))

Creates a publisher that converts any failure from the upstream publisher into a new error.

### Declaring supporting types

[`Publishers.MapError.Output`](/documentation/Combine/Publishers/MapError/Output)

The kind of values published by this publisher.

### Inspecting publisher properties

[`upstream`](/documentation/Combine/Publishers/MapError/upstream)

The publisher from which this publisher receives elements.

[`transform`](/documentation/Combine/Publishers/MapError/transform)

The closure that converts the upstream failure into a new error.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)