SmartAccountException

public class SmartAccountException : Error, CustomStringConvertible, @unchecked Sendable

Base class for every error surfaced by the Smart Account Kit.

Every error path in the kit funnels into a SmartAccountException subclass so callers can rely on a single typed channel for error handling and can map errors back to a stable numeric SmartAccountErrorCode.

Every concrete leaf subclass declares the same init(message: String, cause: Error? = nil).

Example:

do {
    try await kit.createWallet(name: "My Wallet")
} catch let error as WebAuthnException.Cancelled {
    print("User cancelled authentication")
} catch let error as SmartAccountCredentialException.DeploymentFailed {
    print("Deployment failed: \(error.message)")
} catch let error as SmartAccountException {
    print("Smart account error \(error.code.code): \(error.message)")
}
  • Stable numeric error code identifying the condition that triggered this exception.

    Declaration

    Swift

    public let code: SmartAccountErrorCode
  • Human-readable description of the condition.

    Declaration

    Swift

    public let message: String
  • Optional underlying error that caused this exception, preserved for diagnostics.

    Declaration

    Swift

    public let cause: Error?
  • Stable string representation including the numeric code and message, plus the cause’s message when one is present.

    Declaration

    Swift

    public var description: String { get }
  • Wraps an arbitrary error into a SmartAccountException.

    If err is already a SmartAccountException, it is returned unchanged so the original typed information is preserved through pass-through layers. Otherwise a new exception subclass matching defaultCode is constructed, with the original error preserved as cause for diagnostics.

    Declaration

    Swift

    public static func wrapError(
        _ err: Error,
        defaultCode: SmartAccountErrorCode = .invalidInput
    ) -> SmartAccountException

    Parameters

    err

    The error to wrap.

    defaultCode

    The error code to use when wrapping a non-SmartAccountException error. Defaults to .invalidInput.

    Return Value

    A SmartAccountException representing the original error.