fix SuperError
This commit is contained in:
parent
4d9f6b9a42
commit
ae40d46d6f
@ -12,7 +12,7 @@ import CryptoKit
|
|||||||
import Security
|
import Security
|
||||||
|
|
||||||
// 定义错误类型,便于上层处理
|
// 定义错误类型,便于上层处理
|
||||||
enum SDLQUICError: Error {
|
enum SDLSuperError: Error {
|
||||||
case connectionFailed(Error)
|
case connectionFailed(Error)
|
||||||
case connectionCancelled
|
case connectionCancelled
|
||||||
case writeFailed(Error)
|
case writeFailed(Error)
|
||||||
@ -123,7 +123,7 @@ actor SDLSuperClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func finishMessageContinuationIfNeed(throwing error: SDLQUICError?) {
|
private func finishMessageContinuationIfNeed(throwing error: SDLSuperError?) {
|
||||||
guard !self.isMessageContinuationFinished else {
|
guard !self.isMessageContinuationFinished else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ actor SDLSuperClient {
|
|||||||
|
|
||||||
private func readOnce() async throws -> Data {
|
private func readOnce() async throws -> Data {
|
||||||
guard let connection = self.connection else {
|
guard let connection = self.connection else {
|
||||||
throw SDLQUICError.connectionCancelled
|
throw SDLSuperError.connectionCancelled
|
||||||
}
|
}
|
||||||
|
|
||||||
let readContinuation = OnceContinuation<Data, Error>()
|
let readContinuation = OnceContinuation<Data, Error>()
|
||||||
@ -196,7 +196,7 @@ actor SDLSuperClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if isComplete {
|
if isComplete {
|
||||||
readContinuation.resume(throwing: SDLQUICError.dataStreamClosed)
|
readContinuation.resume(throwing: SDLSuperError.dataStreamClosed)
|
||||||
} else {
|
} else {
|
||||||
readContinuation.resume(returning: data ?? Data())
|
readContinuation.resume(returning: data ?? Data())
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ extension SDLSuperClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len > self.maxPacketSize {
|
if len > self.maxPacketSize {
|
||||||
throw SDLQUICError.packetTooLarge
|
throw SDLSuperError.packetTooLarge
|
||||||
}
|
}
|
||||||
|
|
||||||
guard buffer.readableBytes >= len + 2 else {
|
guard buffer.readableBytes >= len + 2 else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user