OLD | NEW |
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // information and so scheduled_test knows we haven't timed out while | 102 // information and so scheduled_test knows we haven't timed out while |
103 // loading transformers. | 103 // loading transformers. |
104 _logRequest(request, "Served $id"); | 104 _logRequest(request, "Served $id"); |
105 request.response.close(); | 105 request.response.close(); |
106 }); | 106 }); |
107 }).catchError((error) { | 107 }).catchError((error) { |
108 _resultsController.add( | 108 _resultsController.add( |
109 new BarbackServerResult._failure(request.uri, id, error)); | 109 new BarbackServerResult._failure(request.uri, id, error)); |
110 | 110 |
111 // If we couldn't read the asset, handle the error gracefully. | 111 // If we couldn't read the asset, handle the error gracefully. |
112 if (error is FileException) { | 112 if (error is FileSystemException) { |
113 // Assume this means the asset was a file-backed source asset | 113 // Assume this means the asset was a file-backed source asset |
114 // and we couldn't read it, so treat it like a missing asset. | 114 // and we couldn't read it, so treat it like a missing asset. |
115 _notFound(request, error); | 115 _notFound(request, error); |
116 return; | 116 return; |
117 } | 117 } |
118 | 118 |
119 var trace = new Trace.from(getAttachedStackTrace(error)); | 119 var trace = new Trace.from(getAttachedStackTrace(error)); |
120 _logRequest(request, "$error\n$trace"); | 120 _logRequest(request, "$error\n$trace"); |
121 | 121 |
122 // Otherwise, it's some internal error. | 122 // Otherwise, it's some internal error. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 bool get isSuccess => error == null; | 281 bool get isSuccess => error == null; |
282 | 282 |
283 /// Whether the request was served unsuccessfully. | 283 /// Whether the request was served unsuccessfully. |
284 bool get isFailure => !isSuccess; | 284 bool get isFailure => !isSuccess; |
285 | 285 |
286 BarbackServerResult._success(this.url, this.id) | 286 BarbackServerResult._success(this.url, this.id) |
287 : error = null; | 287 : error = null; |
288 | 288 |
289 BarbackServerResult._failure(this.url, this.id, this.error); | 289 BarbackServerResult._failure(this.url, this.id, this.error); |
290 } | 290 } |
OLD | NEW |