knock requests : add KnockRequestsException
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright 2024 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.features.knockrequests.impl.data
|
||||
|
||||
sealed class KnockRequestsException : Exception() {
|
||||
data object AcceptAllPartiallyFailed : KnockRequestsException()
|
||||
data object KnockRequestNotFound : KnockRequestsException()
|
||||
}
|
||||
@@ -105,7 +105,7 @@ class KnockRequestsService(
|
||||
if (results.all { it.isSuccess }) {
|
||||
Result.success(Unit)
|
||||
} else {
|
||||
Result.failure(IllegalStateException("Failed to accept all knock requests"))
|
||||
Result.failure(KnockRequestsException.AcceptAllPartiallyFailed)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,6 +140,6 @@ class KnockRequestsService(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun knockRequestNotFoundResult() = Result.failure<Unit>(IllegalArgumentException("Knock request not found"))
|
||||
}
|
||||
|
||||
private fun knockRequestNotFoundResult() = Result.failure<Unit>(KnockRequestsException.KnockRequestNotFound)
|
||||
|
||||
Reference in New Issue
Block a user