Skip to content

Commit 2b3e3c3

Browse files
committed
Only add underlying error if it's present
1 parent 12750b5 commit 2b3e3c3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

FirebaseAI/Sources/Types/Internal/Live/AsyncWebSocket.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,12 @@ struct WebSocketClosedError: Error, Sendable, CustomNSError {
145145
var errorCode: Int { closeCode.rawValue }
146146

147147
var errorUserInfo: [String: Any] {
148-
[
148+
var userInfo: [String: Any] = [
149149
NSLocalizedDescriptionKey: "WebSocket closed with code \(closeCode.rawValue). Reason: \(closeReason)",
150-
NSUnderlyingErrorKey: underlyingError as Any,
151150
]
151+
if let underlyingError {
152+
userInfo[NSUnderlyingErrorKey] = underlyingError
153+
}
154+
return userInfo
152155
}
153156
}

0 commit comments

Comments
 (0)