fix: remove NoKeysProvided error
We're making this invariant impossible in the code paths that hit it
This commit is contained in:
parent
e2900c26de
commit
1e74012656
2 changed files with 2 additions and 6 deletions
|
@ -37,8 +37,5 @@ public sealed class CryptoHandlerException(message: String? = null, cause: Throw
|
|||
/** The passphrase provided for decryption was incorrect. */
|
||||
public class IncorrectPassphraseException(cause: Throwable) : CryptoHandlerException(null, cause)
|
||||
|
||||
/** No keys were provided for encryption. */
|
||||
public class NoKeysProvided(message: String?) : CryptoHandlerException(message, null)
|
||||
|
||||
/** An unexpected error that cannot be mapped to a known type. */
|
||||
public class UnknownError(cause: Throwable) : CryptoHandlerException(null, cause)
|
||||
|
|
|
@ -7,7 +7,6 @@ package app.passwordstore.crypto
|
|||
|
||||
import app.passwordstore.crypto.errors.CryptoHandlerException
|
||||
import app.passwordstore.crypto.errors.IncorrectPassphraseException
|
||||
import app.passwordstore.crypto.errors.NoKeysProvided
|
||||
import app.passwordstore.crypto.errors.UnknownError
|
||||
import com.github.michaelbull.result.Result
|
||||
import com.github.michaelbull.result.mapError
|
||||
|
@ -38,7 +37,7 @@ public class PGPainlessCryptoHandler @Inject constructor() :
|
|||
options: PGPDecryptOptions,
|
||||
): Result<Unit, CryptoHandlerException> =
|
||||
runCatching {
|
||||
if (keys.isEmpty()) throw NoKeysProvided("No keys provided for encryption")
|
||||
require(keys.isNotEmpty())
|
||||
val keyringCollection =
|
||||
keys
|
||||
.map { key -> PGPainless.readKeyRing().secretKeyRing(key.contents) }
|
||||
|
@ -68,7 +67,7 @@ public class PGPainlessCryptoHandler @Inject constructor() :
|
|||
options: PGPEncryptOptions,
|
||||
): Result<Unit, CryptoHandlerException> =
|
||||
runCatching {
|
||||
if (keys.isEmpty()) throw NoKeysProvided("No keys provided for encryption")
|
||||
require(keys.isNotEmpty())
|
||||
val publicKeyRings =
|
||||
keys.mapNotNull(KeyUtils::tryParseKeyring).mapNotNull { keyRing ->
|
||||
when (keyRing) {
|
||||
|
|
Loading…
Reference in a new issue