I have an async function where im using the withUnsafeContinuation method and closure but for some reason Xcode is not letting me pass either 'error' or 'Error' for continuation.resume(throwing:). I get the error "Cannot convert value of type 'any Error'"
public func parseResponseData(data: Data) async throws -> TextResult {
return try await withUnsafeContinuation { continuation in
Task {
do {
let decoder = JSONDecoder()
let result = try await decoder.decode(TextResult.self, from: data)
continuation.resume(returning: result)
} catch {
continuation.resume(throwing: error)
}
}
}
}