Skip to content

Commit

Permalink
chore: resume 내부 분기 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
stealmh committed Nov 30, 2023
1 parent 6c58b3b commit d1082cc
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions Sources/CuteNetwork/Cute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,25 @@ class Cute<EndPoint: EndPointType>: NSObject, NetworkRouter, URLSessionDelegate
return try await withCheckedThrowingContinuation({ value in
petit(root, logAccess: petitLogVisible) { data, response, error in
if let error {
value.resume(throwing: error)
} else if let data {
value.resume(returning: data)
} else {
value.resume(throwing: NetworkError.noData)
value.resume(throwing: error as? NetworkError ?? NetworkError.custom(message: error.localizedDescription))
}

if let response = response as? HTTPURLResponse {
let result = ResponseHandler.handleNetworkResponse(response)
switch result {
case .success:
guard let data else {
value.resume(throwing: NetworkError.custom(message: "데이터를 받지 못했습니다."))
return
}
value.resume(returning: data)
case .failure(let message):
guard let _ = data else {
value.resume(throwing: NetworkError.custom(message: message))
return
}
}
}
}
})
}
Expand Down

0 comments on commit d1082cc

Please sign in to comment.