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
erris already aSmartAccountException, it is returned unchanged so the original typed information is preserved through pass-through layers. Otherwise a new exception subclass matchingdefaultCodeis constructed, with the original error preserved ascausefor diagnostics.Declaration
Swift
public static func wrapError( _ err: Error, defaultCode: SmartAccountErrorCode = .invalidInput ) -> SmartAccountExceptionParameters
errThe error to wrap.
defaultCodeThe error code to use when wrapping a non-
SmartAccountExceptionerror. Defaults to.invalidInput.Return Value
A
SmartAccountExceptionrepresenting the original error.
View on GitHub
Install in Dash