-
Notifications
You must be signed in to change notification settings - Fork 29
Closed
Description
MultiModalLiveClient does a fair amount of custom logic on disconnect:
Google_GenerativeAI/src/GenerativeAI.Live/Models/MultiModalLiveClient.cs
Lines 552 to 573 in 5c2bbf3
| _client.DisconnectionHappened.Subscribe(info => | |
| { | |
| if (info.Type == DisconnectionType.Error) | |
| { | |
| _logger?.LogConnectionClosedWithError(info.Type, info.Exception!); | |
| ErrorOccurred?.Invoke(this, new ErrorEventArgs(info.Exception!)); | |
| } | |
| else if (info.CloseStatus == WebSocketCloseStatus.InvalidPayloadData) | |
| { | |
| //log info.CloseStatusDescription | |
| _logger?.LogConnectionClosedWithInvalidPyload(info.CloseStatusDescription!); | |
| } | |
| else if (info.CloseStatus == WebSocketCloseStatus.InternalServerError && !string.IsNullOrEmpty(info.CloseStatusDescription)) | |
| { | |
| _logger?.LogConnectionClosedWithError(info.Type, info.Exception!); | |
| Disconnected?.Invoke(this, new ErrorMessageEventArgs(info.CloseStatusDescription)); | |
| } | |
| else | |
| { | |
| _logger?.LogConnectionClosed(); | |
| Disconnected?.Invoke(this, EventArgs.Empty); | |
| } |
But if a case arises that isn't handled by its custom logic, it's surprisingly difficult to get at the underlying error. The use case in question was:
- info.Type = ByServer
- info.CloseStatus = PolicyViolation
The info.CloseStatusDescription did contain the proper error message, but that error message is lost in the current logic and there was no clear way to adjust the DisconnectionHappened event before the Start() provoked the error. (See also #79.)
Anyway, long story short I think this handler could be a little more permissive in what it allows back to the user.
Metadata
Metadata
Assignees
Labels
No labels