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

Side by Side Diff: pkg/barback/lib/src/asset_cascade.dart

Issue 22961002: Add more metadata to non-programmatic barback exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Small fix Created 7 years, 4 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
« no previous file with comments | « no previous file | pkg/barback/lib/src/asset_node.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 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 Stream<BuildResult> get results => _resultsController.stream; 59 Stream<BuildResult> get results => _resultsController.stream;
60 final _resultsController = new StreamController<BuildResult>.broadcast(); 60 final _resultsController = new StreamController<BuildResult>.broadcast();
61 61
62 /// A stream that emits any errors from the cascade or the transformers. 62 /// A stream that emits any errors from the cascade or the transformers.
63 /// 63 ///
64 /// This emits errors as they're detected. If an error occurs in one part of 64 /// This emits errors as they're detected. If an error occurs in one part of
65 /// the cascade, unrelated parts will continue building. 65 /// the cascade, unrelated parts will continue building.
66 /// 66 ///
67 /// This will not emit programming errors from barback itself. Those will be 67 /// This will not emit programming errors from barback itself. Those will be
68 /// emitted through the [results] stream's error channel. 68 /// emitted through the [results] stream's error channel.
69 Stream get errors => _errorsController.stream; 69 Stream<BarbackException> get errors => _errorsController.stream;
70 final _errorsController = new StreamController.broadcast(); 70 final _errorsController = new StreamController<BarbackException>.broadcast();
71 71
72 /// The errors that have occurred since the current build started. 72 /// The errors that have occurred since the current build started.
73 /// 73 ///
74 /// This will be empty if no build is occurring. 74 /// This will be empty if no build is occurring.
75 Queue _accumulatedErrors; 75 Queue<BarbackException> _accumulatedErrors;
76 76
77 /// A future that completes when the currently running build process finishes. 77 /// A future that completes when the currently running build process finishes.
78 /// 78 ///
79 /// If no build it in progress, is `null`. 79 /// If no build it in progress, is `null`.
80 Future _processDone; 80 Future _processDone;
81 81
82 /// Whether any source assets have been updated or removed since processing 82 /// Whether any source assets have been updated or removed since processing
83 /// last began. 83 /// last began.
84 var _newChanges = false; 84 var _newChanges = false;
85 85
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // return out-of-date contents for the asset. 181 // return out-of-date contents for the asset.
182 if (_loadingSources.containsKey(id)) _loadingSources[id].cancel(); 182 if (_loadingSources.containsKey(id)) _loadingSources[id].cancel();
183 183
184 _loadingSources[id] = 184 _loadingSources[id] =
185 new CancelableFuture<Asset>(graph.provider.getAsset(id)); 185 new CancelableFuture<Asset>(graph.provider.getAsset(id));
186 _loadingSources[id].whenComplete(() { 186 _loadingSources[id].whenComplete(() {
187 _loadingSources.remove(id); 187 _loadingSources.remove(id);
188 }).then((asset) { 188 }).then((asset) {
189 var controller = _sourceControllerMap[id].setAvailable(asset); 189 var controller = _sourceControllerMap[id].setAvailable(asset);
190 }).catchError((error) { 190 }).catchError((error) {
191 reportError(error); 191 reportError(new AssetLoadException(id, error));
192 192
193 // TODO(nweiz): propagate error information through asset nodes. 193 // TODO(nweiz): propagate error information through asset nodes.
194 _sourceControllerMap.remove(id).setRemoved(); 194 _sourceControllerMap.remove(id).setRemoved();
195 }); 195 });
196 } 196 }
197 } 197 }
198 198
199 /// Removes [removed] from the graph's known set of source assets. 199 /// Removes [removed] from the graph's known set of source assets.
200 void removeSources(Iterable<AssetId> removed) { 200 void removeSources(Iterable<AssetId> removed) {
201 removed.forEach((id) { 201 removed.forEach((id) {
202 // If the source was being loaded, cancel that load. 202 // If the source was being loaded, cancel that load.
203 if (_loadingSources.containsKey(id)) _loadingSources.remove(id).cancel(); 203 if (_loadingSources.containsKey(id)) _loadingSources.remove(id).cancel();
204 204
205 var controller = _sourceControllerMap.remove(id); 205 var controller = _sourceControllerMap.remove(id);
206 // Don't choke if an id is double-removed for some reason. 206 // Don't choke if an id is double-removed for some reason.
207 if (controller != null) controller.setRemoved(); 207 if (controller != null) controller.setRemoved();
208 }); 208 });
209 } 209 }
210 210
211 void reportError(error) { 211 void reportError(BarbackException error) {
212 _accumulatedErrors.add(error); 212 _accumulatedErrors.add(error);
213 _errorsController.add(error); 213 _errorsController.add(error);
214 } 214 }
215 215
216 /// Starts the build process asynchronously if there is work to be done. 216 /// Starts the build process asynchronously if there is work to be done.
217 /// 217 ///
218 /// Returns a future that completes with the background processing is done. 218 /// Returns a future that completes with the background processing is done.
219 /// If there is no work to do, returns a future that completes immediately. 219 /// If there is no work to do, returns a future that completes immediately.
220 /// All errors that occur during processing will be caught (and routed to the 220 /// All errors that occur during processing will be caught (and routed to the
221 /// [results] stream) before they get to the returned future, so it is safe 221 /// [results] stream) before they get to the returned future, so it is safe
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 264
265 // Otherwise, everything is done. 265 // Otherwise, everything is done.
266 return; 266 return;
267 } 267 }
268 268
269 // Process that phase and then loop onto the next. 269 // Process that phase and then loop onto the next.
270 return future.then((_) => _process()); 270 return future.then((_) => _process());
271 }); 271 });
272 } 272 }
273 } 273 }
OLDNEW
« no previous file with comments | « no previous file | pkg/barback/lib/src/asset_node.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698