I need to wrap a function as below from a library into an async function. The error on my First Trial as below is:
Missing argument for parameter 'errorHandler' in call.
How can I wrap it properly? Your comments will be appreciated.
Original Function:
func createConverter(id: String, successHandler: @escaping (Converter) -> Void, errorHandler: @escaping (Error) -> Void) -> Cancellable
func createConverter(id: String) async throws -> Converter {
return await withCheckedThrowingContinuation({
(continuation: CheckedContinuation<Converter, Error>) in
createConverter(id: id) { result in
switch result {
case .success(let converter):
continuation.resume(returning: converter)
case .failure(let error):
continuation.resume(throwing: error)
}
}
})
}