---
title: "cancelMigrationWithError(_:)"
framework: coredata
role: symbol
role_heading: Instance Method
path: "coredata/nsmigrationmanager/cancelmigrationwitherror(_:)"
---

# cancelMigrationWithError(_:)

Cancels the migration with a given error.

## Declaration

```swift
func cancelMigrationWithError(_ error: any Error)
```

## Parameters

- `error`: An error object that describes the reason why the migration is canceled.

## Discussion

Discussion You can invoke this method from anywhere in the migration process to abort the migration. Calling this method causes migrateStore(from:sourceType:options:with:toDestinationURL:destinationType:destinationOptions:) to abort the migration and return error—you should provide an appropriate error to indicate the reason for the cancellation.

## See Also

### Aborting a Migration

- [reset()](coredata/nsmigrationmanager/reset().md)
