aboutsummaryrefslogtreecommitdiffstats
path: root/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoException.kt
blob: 42429a146f8455db22c41f024aa78cea73f197f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package dev.msfjarvis.aps.crypto

public sealed class CryptoException(message: String? = null) : Exception(message)

/** Sealed exception types for [KeyManager]. */
public sealed class KeyManagerException(message: String? = null) : CryptoException(message) {

  /** Store contains no keys. */
  public object NoKeysAvailableException : KeyManagerException("No keys were found")

  /** Key directory does not exist or cannot be accessed. */
  public object KeyDirectoryUnavailableException :
    KeyManagerException("Key directory does not exist")

  /** Failed to delete given key. */
  public object KeyDeletionFailedException : KeyManagerException("Couldn't delete the key file")

  /** Failed to parse the key as a known type. */
  public object InvalidKeyException :
    KeyManagerException("Given key cannot be parsed as a known key type")

  /** No key matching [keyId] could be found. */
  public class KeyNotFoundException(keyId: String) :
    KeyManagerException("No key found with id: $keyId")

  /** Attempting to add another key for [keyId] without requesting a replace. */
  public class KeyAlreadyExistsException(keyId: String) :
    KeyManagerException("Pre-existing key was found for $keyId")
}