File tree Expand file tree Collapse file tree
Sources/NavidromeKit/Extensions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,19 +66,23 @@ internal extension APIClient {
6666 private func fetchData(
6767 for request: URLRequest
6868 ) async throws -> Data {
69+ let data : Data
70+ let response : URLResponse
71+
6972 do {
70- let ( data, response) = try await session. data ( for: request)
71- guard let httpResponse = response as? HTTPURLResponse else { throw APIError . invalidURL }
72-
73- if httpResponse. statusCode == 401 { throw APIError . unauthorized }
74- guard ( 200 ... 299 ) . contains ( httpResponse. statusCode) else {
75- throw APIError . serverError ( httpResponse. statusCode)
76- }
77-
78- return data
73+ ( data, response) = try await session. data ( for: request)
7974 } catch {
8075 throw APIError . requestFailed ( error)
8176 }
77+
78+ guard let httpResponse = response as? HTTPURLResponse else { throw APIError . invalidURL }
79+
80+ if httpResponse. statusCode == 401 { throw APIError . unauthorized }
81+ guard ( 200 ... 299 ) . contains ( httpResponse. statusCode) else {
82+ throw APIError . serverError ( httpResponse. statusCode)
83+ }
84+
85+ return data
8286 }
8387
8488 /// Fetch decoded data for a request
You can’t perform that action at this time.
0 commit comments