OLD | NEW |
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 57 } |
58 | 58 |
59 var id = request is Map ? request['id'] : null; | 59 var id = request is Map ? request['id'] : null; |
60 if (id is! String && id is! num) id = null; | 60 if (id is! String && id is! num) id = null; |
61 return { | 61 return { |
62 'jsonrpc': '2.0', | 62 'jsonrpc': '2.0', |
63 'error': {'code': code, 'message': message, 'data': modifiedData}, | 63 'error': {'code': code, 'message': message, 'data': modifiedData}, |
64 'id': id | 64 'id': id |
65 }; | 65 }; |
66 } | 66 } |
| 67 |
| 68 String toString() { |
| 69 var prefix = "JSON-RPC error $code"; |
| 70 var errorName = error_code.name(code); |
| 71 if (errorName != null) prefix += " ($errorName)"; |
| 72 return "$prefix: $message"; |
| 73 } |
67 } | 74 } |
OLD | NEW |