Skip to content

Commit 189cc5c

Browse files
committed
knock requests : add KnockRequestsException
1 parent eb9b6a7 commit 189cc5c

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright 2024 New Vector Ltd.
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only
5+
* Please see LICENSE in the repository root for full details.
6+
*/
7+
8+
package io.element.android.features.knockrequests.impl.data
9+
10+
sealed class KnockRequestsException : Exception() {
11+
data object AcceptAllPartiallyFailed : KnockRequestsException()
12+
data object KnockRequestNotFound : KnockRequestsException()
13+
}

features/knockrequests/impl/src/main/kotlin/io/element/android/features/knockrequests/impl/data/KnockRequestsService.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class KnockRequestsService(
105105
if (results.all { it.isSuccess }) {
106106
Result.success(Unit)
107107
} else {
108-
Result.failure(IllegalStateException("Failed to accept all knock requests"))
108+
Result.failure(KnockRequestsException.AcceptAllPartiallyFailed)
109109
}
110110
}
111111

@@ -140,6 +140,6 @@ class KnockRequestsService(
140140
}
141141
}
142142
}
143-
144-
private fun knockRequestNotFoundResult() = Result.failure<Unit>(IllegalArgumentException("Knock request not found"))
145143
}
144+
145+
private fun knockRequestNotFoundResult() = Result.failure<Unit>(KnockRequestsException.KnockRequestNotFound)

0 commit comments

Comments
 (0)