# Cannot compile rethrowing async function

**URL:** <https://forums.swift.org/t/cannot-compile-rethrowing-async-function/65488>\
**Category:** Using Swift\
**Created:** [June 10, 2023, 11:47am UTC](https://forums.swift.org/t/cannot-compile-rethrowing-async-function/65488 "2023-06-10T11:47:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pronebird](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/pronebird/32/21721_2.png) [@pronebird](https://forums.swift.org/u/pronebird)\
**Post date:** [June 10, 2023, 11:47am UTC](https://forums.swift.org/t/cannot-compile-rethrowing-async-function/65488/1 "2023-06-10T11:47:30Z")

</div>

Trying to backport `NSPersistentContainer.performBackgroundTask` for iOS \< 15 which has the following signature:

```swift
public func performBackgroundTask<T>(_ block: @escaping (NSManagedObjectContext) throws -> T) async rethrows -> T

```

But getting the following error from compiler (5.8):

> Call can throw, but the error is not handled; a function declared 'rethrows' may only throw if its parameter does

Source:

```swift
extension NSPersistentContainer {

    @backDeployed(before: iOS 15.0)
    public final func performBackgroundTask<T>(_ block: @escaping (NSManagedObjectContext) throws -> T) async rethrows -> T {
        return try await withCheckedThrowingContinuation { continuation in
            performBackgroundTask { context in
                continuation.resume(with: Result { try block(context) })
            }
        }
    }

}

```

Is there any way to guarantee that the function is definitely rethrowing or at least silence the compiler?

ps: maybe that's what I am looking for [Pitch: Fix rethrows checking and add rethrows(unsafe)](https://forums.swift.org/t/pitch-fix-rethrows-checking-and-add-rethrows-unsafe/44863)
