---
title: "cancelRequest(withError:)"
framework: authenticationservices
role: symbol
role_heading: Instance Method
path: "authenticationservices/asaccountauthenticationmodificationextensioncontext/cancelrequest(witherror:)"
---

# cancelRequest(withError:)

Cancels a request with an error.

## Declaration

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

## Parameters

- `error`: An error that indicates the reason for the canceled request.

## Mentioned in

Upgrading Account Security With an Account Authentication Modification Extension

## Discussion

Discussion If the user cancels the request, use the ASExtensionError.Code.userCanceled error code in the error. If the request requires user interaction, use ASExtensionError.Code.userInteractionRequired instead. To include additional information regarding the failure, use ASExtensionLocalizedFailureReasonErrorKey to set a string value in the error’s userInfo dictionary. The system displays this string value to the user.

## See Also

### Handling Requests

- [completeUpgradeToSignInWithApple(userInfo:)](authenticationservices/asaccountauthenticationmodificationextensioncontext/completeupgradetosigninwithapple(userinfo:).md)
- [completeChangePasswordRequest(updatedCredential:userInfo:)](authenticationservices/asaccountauthenticationmodificationextensioncontext/completechangepasswordrequest(updatedcredential:userinfo:).md)
- [getSignInWithAppleUpgradeAuthorization(state:nonce:completionHandler:)](authenticationservices/asaccountauthenticationmodificationextensioncontext/getsigninwithappleupgradeauthorization(state:nonce:completionhandler:).md)
- [ASExtensionLocalizedFailureReasonErrorKey](authenticationservices/asextensionlocalizedfailurereasonerrorkey.md)
