<!--
{
  "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/Publisher/breakpointOnError()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine9PublisherPAAE17breakpointOnErrorAA10PublishersO10BreakpointVy_xGyF"
  },
  "title" : "breakpointOnError()"
}
-->

# breakpointOnError()

Raises a debugger signal upon receiving a failure.

```
func breakpointOnError() -> Publishers.Breakpoint<Self>
```

## Return Value

A publisher that raises a debugger signal upon receiving a failure.

## Discussion

When the upstream publisher fails with an error, this publisher raises the `SIGTRAP` signal, which stops the process in the debugger. Otherwise, this publisher passes through values and completions as-is.

In this example a [`PassthroughSubject`](/documentation/Combine/PassthroughSubject) publishes strings, but its downstream [`tryMap(_:)`](/documentation/Combine/Publisher/tryMap(_:)) operator throws an error. This sends the error downstream as a [`Subscribers.Completion.failure(_:)`](/documentation/Combine/Subscribers/Completion/failure(_:)). The [`breakpointOnError()`](/documentation/Combine/Publisher/breakpointOnError()) operator receives this completion and stops the app in the debugger.

```
 struct CustomError : Error {}
 let publisher = PassthroughSubject<String?, Error>()
 cancellable = publisher
     .tryMap { stringValue in
         throw CustomError()
     }
     .breakpointOnError()
     .sink(
         receiveCompletion: { completion in print("Completion: \(String(describing: completion))") },
         receiveValue: { aValue in print("Result: \(String(describing: aValue))") }
     )

 publisher.send("TEST DATA")

 // Prints: "error: Execution was interrupted, reason: signal SIGTRAP."
 // Depending on your specific environment, the console messages may
 // also include stack trace information, which is not shown here.
```

---

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)