Catch error and return Result in useCases
This commit is contained in:
parent
30f33d36de
commit
b286a52f5b
|
@ -33,8 +33,8 @@ class PauseVoiceBroadcastUseCase @Inject constructor(
|
|||
private val session: Session,
|
||||
) {
|
||||
|
||||
suspend fun execute(roomId: String) {
|
||||
val room = session.getRoom(roomId) ?: return
|
||||
suspend fun execute(roomId: String): Result<Unit> = runCatching {
|
||||
val room = session.getRoom(roomId) ?: error("Unknown roomId: $roomId")
|
||||
|
||||
Timber.d("## PauseVoiceBroadcastUseCase: Pause voice broadcast requested")
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ class ResumeVoiceBroadcastUseCase @Inject constructor(
|
|||
private val session: Session,
|
||||
) {
|
||||
|
||||
suspend fun execute(roomId: String) {
|
||||
val room = session.getRoom(roomId) ?: return
|
||||
suspend fun execute(roomId: String): Result<Unit> = runCatching {
|
||||
val room = session.getRoom(roomId) ?: error("Unknown roomId: $roomId")
|
||||
|
||||
Timber.d("## ResumeVoiceBroadcastUseCase: Resume voice broadcast requested")
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ class StartVoiceBroadcastUseCase @Inject constructor(
|
|||
private val session: Session,
|
||||
) {
|
||||
|
||||
suspend fun execute(roomId: String) {
|
||||
val room = session.getRoom(roomId) ?: return
|
||||
suspend fun execute(roomId: String): Result<Unit> = runCatching {
|
||||
val room = session.getRoom(roomId) ?: error("Unknown roomId: $roomId")
|
||||
|
||||
Timber.d("## StartVoiceBroadcastUseCase: Start voice broadcast requested")
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ class StopVoiceBroadcastUseCase @Inject constructor(
|
|||
private val session: Session,
|
||||
) {
|
||||
|
||||
suspend fun execute(roomId: String) {
|
||||
val room = session.getRoom(roomId) ?: return
|
||||
suspend fun execute(roomId: String): Result<Unit> = runCatching {
|
||||
val room = session.getRoom(roomId) ?: error("Unknown roomId: $roomId")
|
||||
|
||||
Timber.d("## StopVoiceBroadcastUseCase: Stop voice broadcast requested")
|
||||
|
||||
|
|
Loading…
Reference in New Issue