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

Side by Side Diff: sdk/lib/_internal/pub/lib/src/barback/server.dart

Issue 68493003: Ensure that errors have stack traces attached. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | « sdk/lib/_internal/pub/lib/src/barback.dart ('k') | sdk/lib/_internal/pub/lib/src/io.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 pub.barback.server; 5 library pub.barback.server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 10
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 request.response.statusCode = 500; 123 request.response.statusCode = 500;
124 request.response.reasonPhrase = "Internal Error"; 124 request.response.reasonPhrase = "Internal Error";
125 request.response.write(error); 125 request.response.write(error);
126 request.response.close(); 126 request.response.close();
127 }); 127 });
128 }).catchError((error, trace) { 128 }).catchError((error, trace) {
129 if (error is! AssetNotFoundException) { 129 if (error is! AssetNotFoundException) {
130 trace = new Trace.from(trace); 130 trace = new Trace.from(trace);
131 _logRequest(request, "$error\n$trace"); 131 _logRequest(request, "$error\n$trace");
132 132
133 _resultsController.addError(error); 133 _resultsController.addError(error, trace);
134 close(); 134 close();
135 return; 135 return;
136 } 136 }
137 137
138 _resultsController.add( 138 _resultsController.add(
139 new BarbackServerResult._failure(request.uri, id, error)); 139 new BarbackServerResult._failure(request.uri, id, error));
140 _notFound(request, error); 140 _notFound(request, error);
141 }); 141 });
142 } 142 }
143 143
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 socket.add(JSON.encode({"path": urlPath})); 201 socket.add(JSON.encode({"path": urlPath}));
202 } on FormatException catch (ex) { 202 } on FormatException catch (ex) {
203 _webSocketError(socket, ex.message); 203 _webSocketError(socket, ex.message);
204 } 204 }
205 break; 205 break;
206 206
207 default: 207 default:
208 _webSocketError(socket, 'Unknown command "${command["command"]}".'); 208 _webSocketError(socket, 'Unknown command "${command["command"]}".');
209 break; 209 break;
210 } 210 }
211 }, onError: (error) { 211 }, onError: _resultsController.addError, cancelOnError: true);
212 _resultsController.addError(error); 212 }).catchError(_resultsController.addError);
213 }, cancelOnError: true);
214 }).catchError((error) {
215 _resultsController.addError(error);
216 });
217 } 213 }
218 214
219 /// Converts a [url] served by pub serve into an [AssetId] that can be 215 /// Converts a [url] served by pub serve into an [AssetId] that can be
220 /// requested from barback. 216 /// requested from barback.
221 AssetId _urlToId(Uri url) { 217 AssetId _urlToId(Uri url) {
222 var id = specialUrlToId(url); 218 var id = specialUrlToId(url);
223 if (id != null) return id; 219 if (id != null) return id;
224 220
225 // Otherwise, it's a path in current package's web directory. 221 // Otherwise, it's a path in current package's web directory.
226 var parts = path.url.split(url.path); 222 var parts = path.url.split(url.path);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 bool get isSuccess => error == null; 277 bool get isSuccess => error == null;
282 278
283 /// Whether the request was served unsuccessfully. 279 /// Whether the request was served unsuccessfully.
284 bool get isFailure => !isSuccess; 280 bool get isFailure => !isSuccess;
285 281
286 BarbackServerResult._success(this.url, this.id) 282 BarbackServerResult._success(this.url, this.id)
287 : error = null; 283 : error = null;
288 284
289 BarbackServerResult._failure(this.url, this.id, this.error); 285 BarbackServerResult._failure(this.url, this.id, this.error);
290 } 286 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/barback.dart ('k') | sdk/lib/_internal/pub/lib/src/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698