Skip to content

Commit a7d101d

Browse files
authored
1. Add try-catch to catch io exception
2. Update kdoc
1 parent 1227dcd commit a7d101d

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

demo-app/src/main/kotlin/io/getstream/video/android/ui/join/CallJoinViewModel.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import kotlinx.coroutines.flow.flatMapLatest
4545
import kotlinx.coroutines.flow.flowOf
4646
import kotlinx.coroutines.flow.shareIn
4747
import kotlinx.coroutines.launch
48+
import java.io.IOException
4849
import java.util.UUID
4950
import javax.inject.Inject
5051

@@ -142,9 +143,12 @@ class CallJoinViewModel @Inject constructor(
142143
googleSignInClient.signOut()
143144

144145
StreamVideo.instanceOrNull()?.let { streamVideo ->
145-
streamVideo.getDevice().firstOrNull()?.let { device ->
146-
streamVideo.deleteDevice(device)
146+
val device = try {
147+
streamVideo.getDevice().firstOrNull()
148+
} catch (_: IOException) {
149+
null
147150
}
151+
device?.let { streamVideo.deleteDevice(it) }
148152
streamVideo.logOut()
149153
}
150154

stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideo.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import kotlinx.coroutines.Deferred
3535
import kotlinx.coroutines.flow.Flow
3636
import kotlinx.coroutines.flow.MutableStateFlow
3737
import kotlinx.coroutines.flow.StateFlow
38+
import java.io.IOException
3839

3940
/**
4041
* The main interface to control the Video calls. [StreamVideoClient] implements this interface.
@@ -112,7 +113,12 @@ public interface StreamVideo : NotificationHandler {
112113
/**
113114
* Get a cached device used to receive push notifications.
114115
*
116+
* Collecting the returned [Flow] accesses persistent storage and may throw an [IOException]
117+
* if the stored device cannot be read. Consumers that treat device retrieval as a best-effort
118+
* operation should handle [IOException] explicitly without swallowing coroutine cancellation.
119+
*
115120
* @return stream of Device.
121+
* @throws IOException when the returned flow is collected and persistent storage cannot be read.
116122
*/
117123
public fun getDevice(): Flow<Device?>
118124

0 commit comments

Comments
 (0)