| 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 Future _waitForProcess() { | 267 Future _waitForProcess() { |
| 268 if (_processDone != null) return _processDone; | 268 if (_processDone != null) return _processDone; |
| 269 | 269 |
| 270 _accumulatedErrors = new Queue(); | 270 _accumulatedErrors = new Queue(); |
| 271 _numLogErrors = 0; | 271 _numLogErrors = 0; |
| 272 return _processDone = _process().then((_) { | 272 return _processDone = _process().then((_) { |
| 273 // Report the build completion. | 273 // Report the build completion. |
| 274 // TODO(rnystrom): Put some useful data in here. | 274 // TODO(rnystrom): Put some useful data in here. |
| 275 _resultsController.add( | 275 _resultsController.add( |
| 276 new BuildResult(_accumulatedErrors)); | 276 new BuildResult(_accumulatedErrors)); |
| 277 }).catchError((error, stackTrace) { | |
| 278 // If we get here, it's an unexpected error. Runtime errors like missing | |
| 279 // assets should be handled earlier. Errors from transformers or other | |
| 280 // external code that barback calls into should be caught at that API | |
| 281 // boundary. | |
| 282 // | |
| 283 // On the off chance we get here, pipe the error to the results stream | |
| 284 // as an error. That will let applications handle it without it appearing | |
| 285 // in the same path as "normal" errors that get reported. | |
| 286 _resultsController.addError(error, stackTrace); | |
| 287 }).whenComplete(() { | |
| 288 _processDone = null; | 277 _processDone = null; |
| 289 _accumulatedErrors = null; | 278 _accumulatedErrors = null; |
| 290 }); | 279 }); |
| 291 } | 280 } |
| 292 | 281 |
| 293 /// Starts the background processing. | 282 /// Starts the background processing. |
| 294 /// | 283 /// |
| 295 /// Returns a future that completes when all assets have been processed. | 284 /// Returns a future that completes when all assets have been processed. |
| 296 Future _process() { | 285 Future _process() { |
| 297 _newChanges = false; | 286 _newChanges = false; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 312 return null; | 301 return null; |
| 313 } | 302 } |
| 314 | 303 |
| 315 // Process that phase and then loop onto the next. | 304 // Process that phase and then loop onto the next. |
| 316 return future.then((_) => _process()); | 305 return future.then((_) => _process()); |
| 317 }); | 306 }); |
| 318 } | 307 } |
| 319 | 308 |
| 320 String toString() => "cascade for $package"; | 309 String toString() => "cascade for $package"; |
| 321 } | 310 } |
| OLD | NEW |