fix: last resort for socket disconnect crash

Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
Infi 2024-06-06 18:42:40 +02:00
parent 70d572d93a
commit 16216ce6bf
1 changed files with 21 additions and 13 deletions

View File

@ -167,24 +167,32 @@ object RevoltAPI {
try { try {
RealtimeSocket.connect(sessionToken) RealtimeSocket.connect(sessionToken)
} catch (e: Exception) { } catch (e: Exception) {
if (e is SocketException) { try {
Log.d( if (e is SocketException) {
"RevoltAPI", Log.d(
"Socket closed, probably no big deal /// " + e.message "RevoltAPI",
) "Socket closed, probably no big deal /// " + e.message
} else { )
Log.e("RevoltAPI", "WebSocket error", e) } else {
Log.e("RevoltAPI", "WebSocket error", e)
}
RealtimeSocket.updateDisconnectionState(DisconnectionState.Disconnected)
} catch (e: Exception) {
Sentry.captureMessage("Error in socket error handling: $e")
} }
RealtimeSocket.updateDisconnectionState(DisconnectionState.Disconnected)
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
if (e is InterruptedException) { try {
Log.d("RevoltAPI", "Socket interrupted") if (e is InterruptedException) {
} else { Log.d("RevoltAPI", "Socket interrupted")
Log.e("RevoltAPI", "WebSocket error", e) } else {
Log.e("RevoltAPI", "WebSocket error", e)
}
RealtimeSocket.updateDisconnectionState(DisconnectionState.Disconnected)
} catch (e: Exception) {
Sentry.captureMessage("Error in socket error handling: $e")
} }
RealtimeSocket.updateDisconnectionState(DisconnectionState.Disconnected)
} }
} }
} }