diff options
| author | Harsh Shandilya <me@msfjarvis.dev> | 2022-04-27 22:32:36 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-27 17:02:36 +0000 |
| commit | d4a4ac06ed419221d3a1f967ca3a66b1e163ddb8 (patch) | |
| tree | 8f501a3443e4fb422a213fc169f198f23e4fc511 /crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/errors | |
| parent | b8b069364289421a875bdc6227c8554161e26183 (diff) | |
| download | HardenedPass-d4a4ac06ed419221d3a1f967ca3a66b1e163ddb8.tar.gz HardenedPass-d4a4ac06ed419221d3a1f967ca3a66b1e163ddb8.zip | |
crypto-pgpainless: prepare for error handling (#1877)
Diffstat (limited to 'crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/errors')
| -rw-r--r-- | crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/errors/CryptoException.kt | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/errors/CryptoException.kt b/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/errors/CryptoException.kt index 5e911c35..0fb75691 100644 --- a/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/errors/CryptoException.kt +++ b/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/errors/CryptoException.kt @@ -2,7 +2,8 @@ package dev.msfjarvis.aps.crypto.errors import dev.msfjarvis.aps.crypto.KeyManager -public sealed class CryptoException(message: String? = null) : Exception(message) +public sealed class CryptoException(message: String? = null, cause: Throwable? = null) : + Exception(message, cause) /** Sealed exception types for [KeyManager]. */ public sealed class KeyManagerException(message: String? = null) : CryptoException(message) @@ -28,3 +29,13 @@ public class KeyNotFoundException(keyId: String) : /** Attempting to add another key for [keyId] without requesting a replace. */ public class KeyAlreadyExistsException(keyId: String) : KeyManagerException("Pre-existing key was found for $keyId") + +/** Sealed exception types for [CryptoHandler]. */ +public sealed class CryptoHandlerException(message: String? = null, cause: Throwable? = null) : + CryptoException(message, cause) + +/** The passphrase provided for decryption was incorrect. */ +public class IncorrectPassphraseException(cause: Throwable) : CryptoHandlerException(null, cause) + +/** An unexpected error that cannot be mapped to a known type. */ +public class UnknownError(cause: Throwable) : CryptoHandlerException(null, cause) |
