Last active
January 30, 2022 10:07
-
-
Save SebastianBoldt/a76ca2d614927202450c9bd47403244b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum SomeError: Error { | |
case foo | |
} | |
func completionFunction(completion: @escaping ([Data], error: @escaping (Error) -> Void) -> Void) { | |
getData(complete: completion) | |
} | |
func asyncFunctionWrapper() async -> Data { | |
await withCheckedThrowingContinuation { continuation in | |
completionFunction(completion: { data in | |
continuation.resume(returning: data) | |
} error: { | |
contiuation.resume(throwing: SomeError.foo) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment