| 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 protocol; | 5 library protocol; |
| 6 | 6 |
| 7 import 'dart:convert' show JsonDecoder; | 7 import 'dart:convert' show JsonDecoder; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Instances of the class [Request] represent a request that was received. | 10 * Instances of the class [Request] represent a request that was received. |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 result[name] = value; | 258 result[name] = value; |
| 259 } | 259 } |
| 260 | 260 |
| 261 /** | 261 /** |
| 262 * Return a table representing the structure of the Json object that will be | 262 * Return a table representing the structure of the Json object that will be |
| 263 * sent to the client to represent this response. | 263 * sent to the client to represent this response. |
| 264 */ | 264 */ |
| 265 Map<String, Object> toJson() { | 265 Map<String, Object> toJson() { |
| 266 Map jsonObject = new Map(); | 266 Map jsonObject = new Map(); |
| 267 jsonObject[ID] = id; | 267 jsonObject[ID] = id; |
| 268 jsonObject[ERROR] = error.toJson(); | 268 if (error == null) { |
| 269 jsonObject[ERROR] = null; |
| 270 } else { |
| 271 jsonObject[ERROR] = error.toJson(); |
| 272 } |
| 269 if (!result.isEmpty) { | 273 if (!result.isEmpty) { |
| 270 jsonObject[RESULT] = result; | 274 jsonObject[RESULT] = result; |
| 271 } | 275 } |
| 272 return jsonObject; | 276 return jsonObject; |
| 273 } | 277 } |
| 274 } | 278 } |
| 275 | 279 |
| 276 /** | 280 /** |
| 277 * Instances of the class [RequestError] represent information about an error th
at | 281 * Instances of the class [RequestError] represent information about an error th
at |
| 278 * occurred while attempting to respond to a [Request]. | 282 * occurred while attempting to respond to a [Request]. |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 /** | 491 /** |
| 488 * The response to be returned as a result of the failure. | 492 * The response to be returned as a result of the failure. |
| 489 */ | 493 */ |
| 490 final Response response; | 494 final Response response; |
| 491 | 495 |
| 492 /** | 496 /** |
| 493 * Initialize a newly created exception to return the given reponse. | 497 * Initialize a newly created exception to return the given reponse. |
| 494 */ | 498 */ |
| 495 RequestFailure(this.response); | 499 RequestFailure(this.response); |
| 496 } | 500 } |
| OLD | NEW |