Web3RpcError class

Provider-side error that mirrors EIP-1193 / EIP-3326 error semantics.

Scope

Web3RpcError standardises how the Flutter layer signals provider-level failures (code + message) instead of using opaque Exception strings. Down-stream wallet code can catch (e) { if (e is Web3RpcError) … } and reason about the failure structurally.

Reaching the in-page DApp: the flutter_inappwebview bridge re-wraps the exception (see flutter_inappwebview_ios/in_app_webview_controller.dart:onCallJsHandler), so the JavaScript side receives a string of roughly the form Error: …, Exception: Web3RpcError: {"code":4001,...}. The injected provider bridge (provider/packages/core/adapter/FlutterBridge.ts) matches the sentinel below, parses the trailing JSON, and re-throws a real EIP-1193 ProviderRpcError carrying code / message / data, so DApps can branch on error.code (e.g. 4902wallet_addEthereumChain).

The toString output prefixes the JSON with a stable Web3RpcError: sentinel so the future bridge code can match it with a single regex even after the platform layer has wrapped the message further.

Implemented types

Constructors

Web3RpcError(int code, String message, {Object? data})
const
Web3RpcError.cancelled([String message = 'Request cancelled'])
The request was cancelled by the wallet before it produced a result.
factory
Web3RpcError.internal([String message = 'Internal wallet error'])
Internal wallet failure (JSON-RPC -32603).
factory
Web3RpcError.limitExceeded([String message = 'Too many pending requests'])
Too many provider requests are already waiting for the wallet.
factory
Web3RpcError.requestUnavailable([String message = 'Request temporarily unavailable, please retry'])
The wallet cannot serve the request right now: a state switch is in flight, the request was superseded, or a temporary safety gate is closed.
factory
Web3RpcError.unauthorized([String message = 'Unauthorized'])
The calling document holds no account grant (EIP-1193 4100).
factory
Web3RpcError.unrecognizedChain([String message = 'Unrecognized chain ID'])
The chain referenced by the request has not been added to the wallet, or the request did not include a usable chain id.
factory
Web3RpcError.unsupportedMethod([String message = 'Unsupported method'])
The wallet does not support the requested method (EIP-1193 4200).
factory
Web3RpcError.userRejected([String message = 'User rejected the request'])
User explicitly rejected the request.
factory

Properties

code int
EIP-1193 / EIP-3326 numeric error code.
final
data Object?
final
hashCode int
The hash code for this object.
no setterinherited
message String
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

sentinel → const String
Sentinel that prefixes toString output so the provider bridge can reliably locate the JSON payload inside the wrapped exception string.