<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 11.0.0 -",
    "macOS: 10.15.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FileProviderUI",
  "identifier" : "/documentation/FileProviderUI/FPUIActionExtensionContext/cancelRequest(withError:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "File Provider UI"
    ],
    "preciseIdentifier" : "c:objc(cs)FPUIActionExtensionContext(im)cancelRequestWithError:"
  },
  "title" : "cancelRequest(withError:)"
}
-->

# cancelRequest(withError:)

Cancels the action and returns the provided error.

```
func cancelRequest(withError error: any Error)
```

## Discussion

Call this method if the action fails. Set the error’s domain to [`FPUIErrorDomain`](/documentation/FileProviderUI/FPUIErrorDomain). Set the error code to a [`FPUIExtensionErrorCode`](/documentation/FileProviderUI/FPUIExtensionErrorCode) value.

---

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)