knock requests : add KnockRequestsException

This commit is contained in:
ganfra 2024-12-19 19:31:53 +01:00
parent eb9b6a72ee
commit 189cc5c58e
2 changed files with 16 additions and 3 deletions

View file

@ -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()
}

View file

@ -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)