Skip to content

Commit

Permalink
Catch error and return Result in useCases
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Renaud committed Oct 6, 2022
1 parent 30f33d3 commit b286a52
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit b286a52

Please sign in to comment.