Better error handling

This commit is contained in:
Leon Böttger authored and Leon Böttger committed 2026-03-08 15:44:25 +01:00
1 parent 7fbe254118
commit e828edd6ae
1 file changed
+8 -1
@@ -189,7 +189,14 @@ class NearbyConnection {
}
guard let content = content else {
log("[NearbyConnection \(self.id)] Received nil content during receiveFrameAsync(). IsComplete: \(isComplete)")
assertionFailure()
self.lastError = NearbyError.protocolError("Received empty frame header")
self.protocolError()
return
}
guard content.count == 4 else {
log("[NearbyConnection \(self.id)] Received invalid frame header size \(content.count), expected 4")
self.lastError = NearbyError.protocolError("Unexpected frame header length")
self.protocolError()
return
}
let frameLength = UInt32(content[0]) << 24 | UInt32(content[1]) << 16 | UInt32(content[2]) << 8 | UInt32(content[3])