wrapError

fun wrapError(err: Throwable, defaultCode: SmartAccountErrorCode = SmartAccountErrorCode.INVALID_INPUT): SmartAccountException

Wraps an arbitrary Throwable into a SmartAccountException.

If the throwable is already a SmartAccountException, it is returned as-is. Otherwise, a new exception subclass matching defaultCode is created, preserving the original throwable as cause.

Ensures all errors surfaced from the Smart Account Kit are consistently typed.

Return

A SmartAccountException wrapping the original error

Parameters

err

The throwable to wrap

defaultCode

The error code to use when wrapping non-SmartAccountException errors. Defaults to SmartAccountErrorCode.INVALID_INPUT.