serialize method
Converts this exception into a JSON-serializable object that's a valid JSON-RPC 2.0 error response.
Implementation
Map<String, dynamic> serialize(request) {
Map modifiedData;
final data = this.data;
if (data is Map && !data.containsKey('request')) {
modifiedData = Map.from(data);
modifiedData['request'] = request;
} else if (data == null) {
modifiedData = {'request': request};
} else {
modifiedData = data;
}
var id = request is Map ? request['id'] : null;
if (id is! String && id is! num) id = null;
return {
'jsonrpc': '2.0',
'error': {'code': code, 'message': message, 'data': modifiedData},
'id': id
};
}