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 barback.asset_cascade; | 5 library barback.asset_cascade; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'asset.dart'; | 10 import 'asset.dart'; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 Future _waitForProcess() { | 259 Future _waitForProcess() { |
260 if (_processDone != null) return _processDone; | 260 if (_processDone != null) return _processDone; |
261 | 261 |
262 _accumulatedErrors = new Queue(); | 262 _accumulatedErrors = new Queue(); |
263 _numLogErrors = 0; | 263 _numLogErrors = 0; |
264 return _processDone = _process().then((_) { | 264 return _processDone = _process().then((_) { |
265 // Report the build completion. | 265 // Report the build completion. |
266 // TODO(rnystrom): Put some useful data in here. | 266 // TODO(rnystrom): Put some useful data in here. |
267 _resultsController.add( | 267 _resultsController.add( |
268 new BuildResult(_accumulatedErrors)); | 268 new BuildResult(_accumulatedErrors)); |
269 }).catchError((error) { | 269 }).catchError((error, stackTrace) { |
270 // If we get here, it's an unexpected error. Runtime errors like missing | 270 // If we get here, it's an unexpected error. Runtime errors like missing |
271 // assets should be handled earlier. Errors from transformers or other | 271 // assets should be handled earlier. Errors from transformers or other |
272 // external code that barback calls into should be caught at that API | 272 // external code that barback calls into should be caught at that API |
273 // boundary. | 273 // boundary. |
274 // | 274 // |
275 // On the off chance we get here, pipe the error to the results stream | 275 // On the off chance we get here, pipe the error to the results stream |
276 // as an error. That will let applications handle it without it appearing | 276 // as an error. That will let applications handle it without it appearing |
277 // in the same path as "normal" errors that get reported. | 277 // in the same path as "normal" errors that get reported. |
278 _resultsController.addError(error); | 278 _resultsController.addError(error, stackTrace); |
279 }).whenComplete(() { | 279 }).whenComplete(() { |
280 _processDone = null; | 280 _processDone = null; |
281 _accumulatedErrors = null; | 281 _accumulatedErrors = null; |
282 }); | 282 }); |
283 } | 283 } |
284 | 284 |
285 /// Starts the background processing. | 285 /// Starts the background processing. |
286 /// | 286 /// |
287 /// Returns a future that completes when all assets have been processed. | 287 /// Returns a future that completes when all assets have been processed. |
288 Future _process() { | 288 Future _process() { |
(...skipping 13 matching lines...) Expand all Loading... |
302 | 302 |
303 // Otherwise, everything is done. | 303 // Otherwise, everything is done. |
304 return null; | 304 return null; |
305 } | 305 } |
306 | 306 |
307 // Process that phase and then loop onto the next. | 307 // Process that phase and then loop onto the next. |
308 return future.then((_) => _process()); | 308 return future.then((_) => _process()); |
309 }); | 309 }); |
310 } | 310 } |
311 } | 311 } |
OLD | NEW |