Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Side by Side Diff: pkg/json_rpc_2/lib/src/exception.dart

Issue 224903010: Pass RpcException error data through if it's not a map. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/json_rpc_2/CHANGELOG.md ('k') | pkg/json_rpc_2/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library json_rpc_2.exception; 5 library json_rpc_2.exception;
6 6
7 import '../error_code.dart' as error_code; 7 import '../error_code.dart' as error_code;
8 8
9 /// An exception from a JSON-RPC server that can be translated into an error 9 /// An exception from a JSON-RPC server that can be translated into an error
10 /// response. 10 /// response.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 /// Converts this exception into a JSON-serializable object that's a valid 46 /// Converts this exception into a JSON-serializable object that's a valid
47 /// JSON-RPC 2.0 error response. 47 /// JSON-RPC 2.0 error response.
48 serialize(request) { 48 serialize(request) {
49 var modifiedData; 49 var modifiedData;
50 if (data is Map && !data.containsKey('request')) { 50 if (data is Map && !data.containsKey('request')) {
51 modifiedData = new Map.from(data); 51 modifiedData = new Map.from(data);
52 modifiedData['request'] = request; 52 modifiedData['request'] = request;
53 } else if (data == null) { 53 } else if (data == null) {
54 modifiedData = {'request': request}; 54 modifiedData = {'request': request};
55 } else {
56 modifiedData = data;
55 } 57 }
56 58
57 var id = request is Map ? request['id'] : null; 59 var id = request is Map ? request['id'] : null;
58 if (id is! String && id is! num) id = null; 60 if (id is! String && id is! num) id = null;
59 return { 61 return {
60 'jsonrpc': '2.0', 62 'jsonrpc': '2.0',
61 'error': {'code': code, 'message': message, 'data': modifiedData}, 63 'error': {'code': code, 'message': message, 'data': modifiedData},
62 'id': id 64 'id': id
63 }; 65 };
64 } 66 }
65 } 67 }
OLDNEW
« no previous file with comments | « pkg/json_rpc_2/CHANGELOG.md ('k') | pkg/json_rpc_2/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698