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

Side by Side Diff: pkg/analysis_server/lib/src/protocol.dart

Issue 282993002: Leave "error" key out of response JSON when there is no error. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 | « no previous file | pkg/analysis_server/test/domain_context_test.dart » ('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 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 result[name] = value; 405 result[name] = value;
406 } 406 }
407 407
408 /** 408 /**
409 * Return a table representing the structure of the Json object that will be 409 * Return a table representing the structure of the Json object that will be
410 * sent to the client to represent this response. 410 * sent to the client to represent this response.
411 */ 411 */
412 Map<String, Object> toJson() { 412 Map<String, Object> toJson() {
413 Map<String, Object> jsonObject = new Map<String, Object>(); 413 Map<String, Object> jsonObject = new Map<String, Object>();
414 jsonObject[ID] = id; 414 jsonObject[ID] = id;
415 if (error == null) { 415 if (error != null) {
416 jsonObject[ERROR] = null;
417 } else {
418 jsonObject[ERROR] = error.toJson(); 416 jsonObject[ERROR] = error.toJson();
419 } 417 }
420 if (!result.isEmpty) { 418 if (!result.isEmpty) {
421 jsonObject[RESULT] = result; 419 jsonObject[RESULT] = result;
422 } 420 }
423 return jsonObject; 421 return jsonObject;
424 } 422 }
425 } 423 }
426 424
427 /** 425 /**
(...skipping 16 matching lines...) Expand all
444 /** 442 /**
445 * The name of the JSON attribute containing a short description of the error. 443 * The name of the JSON attribute containing a short description of the error.
446 */ 444 */
447 static const String MESSAGE = 'message'; 445 static const String MESSAGE = 'message';
448 446
449 /** 447 /**
450 * An error code indicating a parse error. Invalid JSON was received by the 448 * An error code indicating a parse error. Invalid JSON was received by the
451 * server. An error occurred on the server while parsing the JSON text. 449 * server. An error occurred on the server while parsing the JSON text.
452 */ 450 */
453 static const int CODE_PARSE_ERROR = -32700; 451 static const int CODE_PARSE_ERROR = -32700;
454 452
455 /** 453 /**
456 * An error code indicating that the analysis server has already been 454 * An error code indicating that the analysis server has already been
457 * started (and hence won't accept new connections). 455 * started (and hence won't accept new connections).
458 */ 456 */
459 static const int CODE_SERVER_ALREADY_STARTED = -32701; 457 static const int CODE_SERVER_ALREADY_STARTED = -32701;
460 458
461 /** 459 /**
462 * An error code indicating an invalid request. The JSON sent is not a valid 460 * An error code indicating an invalid request. The JSON sent is not a valid
463 * [Request] object. 461 * [Request] object.
464 */ 462 */
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 * the JSON text. 514 * the JSON text.
517 */ 515 */
518 RequestError.parseError() : this(CODE_PARSE_ERROR, "Parse error"); 516 RequestError.parseError() : this(CODE_PARSE_ERROR, "Parse error");
519 517
520 /** 518 /**
521 * Initialize a newly created [Error] to indicate that the analysis server 519 * Initialize a newly created [Error] to indicate that the analysis server
522 * has already been started (and hence won't accept new connections). 520 * has already been started (and hence won't accept new connections).
523 */ 521 */
524 RequestError.serverAlreadyStarted() 522 RequestError.serverAlreadyStarted()
525 : this(CODE_SERVER_ALREADY_STARTED, "Server already started"); 523 : this(CODE_SERVER_ALREADY_STARTED, "Server already started");
526 524
527 /** 525 /**
528 * Initialize a newly created [Error] to indicate an invalid request. The 526 * Initialize a newly created [Error] to indicate an invalid request. The
529 * JSON sent is not a valid [Request] object. 527 * JSON sent is not a valid [Request] object.
530 */ 528 */
531 RequestError.invalidRequest() : this(CODE_INVALID_REQUEST, "Invalid request"); 529 RequestError.invalidRequest() : this(CODE_INVALID_REQUEST, "Invalid request");
532 530
533 /** 531 /**
534 * Initialize a newly created [Error] to indicate that a method was not found. 532 * Initialize a newly created [Error] to indicate that a method was not found.
535 * Either the method does not exist or is not currently available. 533 * Either the method does not exist or is not currently available.
536 */ 534 */
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 /** 693 /**
696 * The response to be returned as a result of the failure. 694 * The response to be returned as a result of the failure.
697 */ 695 */
698 final Response response; 696 final Response response;
699 697
700 /** 698 /**
701 * Initialize a newly created exception to return the given reponse. 699 * Initialize a newly created exception to return the given reponse.
702 */ 700 */
703 RequestFailure(this.response); 701 RequestFailure(this.response);
704 } 702 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/domain_context_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698