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

Side by Side Diff: pkg/analysis_server/test/protocol_test.dart

Issue 569743003: update error handling to send response with stack trace (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 3 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
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 test.protocol; 5 library test.protocol;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:analysis_server/src/constants.dart'; 9 import 'package:analysis_server/src/constants.dart';
10 import 'package:analysis_server/src/protocol.dart'; 10 import 'package:analysis_server/src/protocol.dart';
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 RequestError error = new RequestError(RequestErrorCode.INVALID_REQUEST, 'msg '); 98 RequestError error = new RequestError(RequestErrorCode.INVALID_REQUEST, 'msg ');
99 expect(error.code, RequestErrorCode.INVALID_REQUEST); 99 expect(error.code, RequestErrorCode.INVALID_REQUEST);
100 expect(error.message, "msg"); 100 expect(error.message, "msg");
101 expect(error.toJson(), equals({ 101 expect(error.toJson(), equals({
102 CODE: 'INVALID_REQUEST', 102 CODE: 'INVALID_REQUEST',
103 MESSAGE: "msg" 103 MESSAGE: "msg"
104 })); 104 }));
105 } 105 }
106 106
107 void test_fromJson() { 107 void test_fromJson() {
108 var trace = 'a stack trace\r\nfoo';
108 var json = { 109 var json = {
109 CODE: RequestErrorCode.INVALID_PARAMETER.name, 110 CODE: RequestErrorCode.INVALID_PARAMETER.name,
110 MESSAGE: 'foo', 111 MESSAGE: 'foo',
111 DATA: { 112 STACK_TRACE: trace
112 'ints': [1, 2, 3]
113 }
114 }; 113 };
115 RequestError error = new RequestError.fromJson(new ResponseDecoder(null), '' , 114 RequestError error = new RequestError.fromJson(new ResponseDecoder(null), '' ,
116 json); 115 json);
117 expect(error.code, RequestErrorCode.INVALID_PARAMETER); 116 expect(error.code, RequestErrorCode.INVALID_PARAMETER);
118 expect(error.message, "foo"); 117 expect(error.message, "foo");
119 expect(error.data['ints'], [1, 2, 3]); 118 expect(error.stackTrace, trace);
120 } 119 }
121 120
122 void test_toJson() { 121 void test_toJson() {
122 var trace = 'a stack trace\r\nbar';
123 RequestError error = new RequestError( 123 RequestError error = new RequestError(
124 RequestErrorCode.UNKNOWN_REQUEST, 'msg', data: {}); 124 RequestErrorCode.UNKNOWN_REQUEST, 'msg', stackTrace: trace);
125 error.data['answer'] = 42;
126 error.data['question'] = 'unknown';
127 expect(error.toJson(), { 125 expect(error.toJson(), {
128 CODE: 'UNKNOWN_REQUEST', 126 CODE: 'UNKNOWN_REQUEST',
129 MESSAGE: 'msg', 127 MESSAGE: 'msg',
130 DATA: { 128 STACK_TRACE: trace
131 'answer': 42,
132 'question': 'unknown'
133 }
134 }); 129 });
135 } 130 }
136 } 131 }
137 132
138 133
139 @ReflectiveTestCase() 134 @ReflectiveTestCase()
140 class RequestTest { 135 class RequestTest {
141 void test_fromJson() { 136 void test_fromJson() {
142 Request original = new Request('one', 'aMethod'); 137 Request original = new Request('one', 'aMethod');
143 String json = JSON.encode(original.toJson()); 138 String json = JSON.encode(original.toJson());
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 251
257 void test_fromJson_withResult() { 252 void test_fromJson_withResult() {
258 Response original = new Response('myId', result: {'foo': 'bar'}); 253 Response original = new Response('myId', result: {'foo': 'bar'});
259 Response response = new Response.fromJson(original.toJson()); 254 Response response = new Response.fromJson(original.toJson());
260 expect(response.id, equals('myId')); 255 expect(response.id, equals('myId'));
261 Map<String, Object> result = response.toJson()['result']; 256 Map<String, Object> result = response.toJson()['result'];
262 expect(result.length, equals(1)); 257 expect(result.length, equals(1));
263 expect(result['foo'], equals('bar')); 258 expect(result['foo'], equals('bar'));
264 } 259 }
265 } 260 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/integration/protocol_matchers.dart ('k') | pkg/analysis_server/test/socket_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698