TrustWeaveException

open class TrustWeaveException(val code: String, val message: String, val context: Map<String, Any?> = emptyMap(), val cause: Throwable? = null) : Exception

Base exception hierarchy for all TrustWeave operations.

All TrustWeave exceptions provide structured error codes and context for better error handling and debugging.

Design Note: This is an open class to allow domain-specific exception hierarchies (DidException, WalletException, BlockchainException, etc.) in other modules to extend it. Domain-specific exception classes are typically sealed for exhaustive handling within their respective domains.

Exception Hierarchy:

  • PluginException — plugin lifecycle errors (not found, init failed, etc.)

  • ProviderException — provider chain errors (none found, partial, all failed)

  • ConfigException — configuration errors (not found, read failed, invalid format)

  • SerializationException — JSON / serialization errors

  • Core generic exceptions (in this class) — validation, encoding, digest, etc.

  • Domain exceptions (in other modules) — DidException, WalletException, etc.

Inheritors

Constructors

Link copied to clipboard
constructor(code: String, message: String, context: Map<String, Any?> = emptyMap(), cause: Throwable? = null)

Types

Link copied to clipboard
data class DigestFailed(val algorithm: String, val reason: String) : TrustWeaveException
Link copied to clipboard
data class EncodeFailed(val operation: String, val reason: String) : TrustWeaveException
Link copied to clipboard
data class InvalidOperation(val code: String = "INVALID_OPERATION", val message: String, val context: Map<String, Any?> = emptyMap(), val cause: Throwable? = null) : TrustWeaveException
Link copied to clipboard
data class InvalidState(val code: String = "INVALID_STATE", val message: String, val context: Map<String, Any?> = emptyMap(), val cause: Throwable? = null) : TrustWeaveException
Link copied to clipboard
data class NotFound(val resource: String? = null, val message: String = resource?.let { "Resource not found: $it" } ?: "Resource not found", baseContext: Map<String, Any?> = emptyMap(), val cause: Throwable? = null) : TrustWeaveException
Link copied to clipboard
data class OperationTimedOut(val operation: String, val timeout: String, val cause: Throwable? = null) : TrustWeaveException

An operation exceeded its configured timeout.

Link copied to clipboard
data class Unknown(val code: String = "UNKNOWN_ERROR", val message: String, val context: Map<String, Any?> = emptyMap(), val cause: Throwable? = null) : TrustWeaveException
Link copied to clipboard
data class UnsupportedAlgorithm(val algorithm: String, val supportedAlgorithms: List<String>) : TrustWeaveException
Link copied to clipboard
data class ValidationFailed(val field: String, val reason: String, val value: Any? = null) : TrustWeaveException

Properties

Link copied to clipboard
open override val cause: Throwable?
Link copied to clipboard
open val code: String
Link copied to clipboard
open val context: Map<String, Any?>

Context map containing additional error information.

Link copied to clipboard
open override val message: String

Functions

Link copied to clipboard

Checks if the exception is configuration-related (i.e., an instance of ConfigException).

Link copied to clipboard

Checks if the exception is encoding/digest-related.

Link copied to clipboard

Checks if the exception is serialization/JSON-related (i.e., an instance of SerializationException).

Link copied to clipboard

Checks if the exception is plugin-related (i.e., an instance of PluginException).

Link copied to clipboard

Checks if the exception is provider-related (i.e., an instance of ProviderException).

Link copied to clipboard

Checks if the exception is validation-related.

Link copied to clipboard

Extension function to convert any Throwable to a TrustWeaveException.