/// JSON-RPC exception class JsonRpcException implements Exception { String? message; int? code; dynamic data; JsonRpcException({ this.code, this.message, this.data, }); @override String toString() { return 'JSON-RPC Exception: $code $message'; } Map toJson() { var map = {'code': code, 'message': message}; if (data != null) { map['data'] = data; } return map; } } /// JSON-RPC network exception class JsonRpcNetworkException extends JsonRpcException { JsonRpcNetworkException(String message, [code = -32000, data]) : super(message: message); } /// JSON-RPC Server Error class JsonRpcServerError extends JsonRpcException { JsonRpcServerError(String message, [code = -32000, data]) : super(message: message, code: code, data: data); JsonRpcServerError.fromJson(Map e) : super() { if (e.containsKey('message')) { message = e['message']; } if (e.containsKey('code')) { code = e['code']; } if (e.containsKey('data')) { data = e['data']; } } }