From 9749e94eb00e6e577dbff778ee404f9ef100d648 Mon Sep 17 00:00:00 2001 From: Sixten Otto Date: Fri, 17 Feb 2023 12:33:45 -0700 Subject: [PATCH] results of data call are not Optional --- .../Sources/Services/AudioSession/SpeechSynthesizer.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apple/OmnivoreKit/Sources/Services/AudioSession/SpeechSynthesizer.swift b/apple/OmnivoreKit/Sources/Services/AudioSession/SpeechSynthesizer.swift index c65aa2514..bd6fe5228 100644 --- a/apple/OmnivoreKit/Sources/Services/AudioSession/SpeechSynthesizer.swift +++ b/apple/OmnivoreKit/Sources/Services/AudioSession/SpeechSynthesizer.swift @@ -175,13 +175,13 @@ struct SpeechSynthesizer { static func downloadData(session: URLSession, request: URLRequest) async throws -> Data { do { - let result: (Data, URLResponse)? = try await session.data(for: request) - guard let httpResponse = result?.1 as? HTTPURLResponse, 200 ..< 300 ~= httpResponse.statusCode else { - print("error: ", result?.1) + let (data, response) = try await session.data(for: request) + guard let httpResponse = response as? HTTPURLResponse, 200 ..< 300 ~= httpResponse.statusCode else { + print("error: ", response) throw BasicError.message(messageText: "audioFetch failed. no response or bad status code.") } - guard let data = result?.0 else { + guard !data.isEmpty else { throw BasicError.message(messageText: "audioFetch failed. no data received.") }