KmsErrorHandler

Shared logging and failure conversion for KMS implementations.

Functions

Link copied to clipboard
fun createErrorContext(keyId: KeyId? = null, algorithm: Algorithm? = null, operation: String? = null, additional: Map<String, Any?> = emptyMap()): Map<String, Any?>

Creates logging context; additional fields override standard fields with the same name.

Link copied to clipboard
fun <T> handleGenericError(logger: Logger, context: Map<String, Any?>, operation: String, e: Exception): T?

Logs an ordinary failure and returns null. Cancellation and interruption propagate without being logged as operation failures.

Link copied to clipboard
fun handleGenericException(logger: Logger, keyId: KeyId? = null, algorithm: Algorithm? = null, operation: String, e: Exception): GenerateKeyResult.Failure?

Logs an ordinary exception and converts it to a key-generation failure when algorithm is supplied, otherwise returns null. Cancellation and interruption propagate unchanged.