Skip to content

Commit 1896b58

Browse files
committed
preserve TimeoutError
1 parent 19228ac commit 1896b58

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

Sources/Timeout.swift

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,12 @@ private func _withThrowingTimeout<T>(
9999
bodyTask.cancel()
100100
}
101101
timeoutTask.cancel()
102-
let timeoutResult = await timeoutTask.result
103102

104-
switch bodyResult {
105-
case .success(let bodySuccess):
106-
return bodySuccess
107-
case .failure(let bodyError):
108-
if case .failure(let timeoutError) = timeoutResult, timeoutError is TimeoutError {
109-
throw timeoutError
110-
} else {
111-
throw bodyError
112-
}
103+
if case .failure(let timeoutError) = await timeoutTask.result,
104+
timeoutError is TimeoutError {
105+
throw timeoutError
106+
} else {
107+
return try bodyResult.get()
113108
}
114109
}
115110
}

0 commit comments

Comments
 (0)