<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Distributed/DistributedTargetInvocationResultHandler/onThrow(error:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Distributed"
    ],
    "preciseIdentifier" : "s:11Distributed0A29TargetInvocationResultHandlerP7onThrow5erroryqd___tYaKs5ErrorRd__lF"
  },
  "title" : "onThrow(error:)"
}
-->

# onThrow(error:)

Invoked when the distributed target execution of a target has thrown an error.

```
func onThrow<Err>(error: Err) async throws where Err : Error
```

## Discussion

It is not guaranteed that the error conform to the [`SerializationRequirement`](/documentation/Distributed/DistributedTargetInvocationResultHandler/SerializationRequirement);
This guarantee is only given to return values (and offered by `onReturn`).

---

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)