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

Side by Side Diff: pkg/barback/lib/src/package_graph.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 | « pkg/barback/lib/src/errors.dart ('k') | pkg/barback/lib/src/phase.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.package_graph; 5 library barback.package_graph;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:stack_trace/stack_trace.dart'; 9 import 'package:stack_trace/stack_trace.dart';
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 Stream<BuildResult> get results => _resultsController.stream; 45 Stream<BuildResult> get results => _resultsController.stream;
46 final _resultsController = new StreamController<BuildResult>.broadcast(); 46 final _resultsController = new StreamController<BuildResult>.broadcast();
47 47
48 /// A stream that emits any errors from the graph or the transformers. 48 /// A stream that emits any errors from the graph or the transformers.
49 /// 49 ///
50 /// This emits errors as they're detected. If an error occurs in one part of 50 /// This emits errors as they're detected. If an error occurs in one part of
51 /// the graph, unrelated parts will continue building. 51 /// the graph, unrelated parts will continue building.
52 /// 52 ///
53 /// This will not emit programming errors from barback itself. Those will be 53 /// This will not emit programming errors from barback itself. Those will be
54 /// emitted through the [results] stream's error channel. 54 /// emitted through the [results] stream's error channel.
55 Stream get errors => _errors; 55 Stream<BarbackException> get errors => _errors;
56 Stream _errors; 56 Stream<BarbackException> _errors;
57 57
58 /// Creates a new [PackageGraph] that will transform assets in all packages 58 /// Creates a new [PackageGraph] that will transform assets in all packages
59 /// made available by [provider]. 59 /// made available by [provider].
60 PackageGraph(this.provider) { 60 PackageGraph(this.provider) {
61 for (var package in provider.packages) { 61 for (var package in provider.packages) {
62 var cascade = new AssetCascade(this, package, 62 var cascade = new AssetCascade(this, package,
63 provider.getTransformers(package)); 63 provider.getTransformers(package));
64 // The initial result for each cascade is "success" since the cascade 64 // The initial result for each cascade is "success" since the cascade
65 // doesn't start building until some source in that graph is updated. 65 // doesn't start building until some source in that graph is updated.
66 _cascadeResults[package] = new BuildResult.success(); 66 _cascadeResults[package] = new BuildResult.success();
67 _cascades[package] = cascade; 67 _cascades[package] = cascade;
68 68
69 cascade.results.listen((result) { 69 cascade.results.listen((result) {
70 _cascadeResults[cascade.package] = result; 70 _cascadeResults[cascade.package] = result;
71 // If any cascade hasn't yet finished, the overall build isn't finished 71 // If any cascade hasn't yet finished, the overall build isn't finished
72 // either. 72 // either.
73 if (_cascadeResults.values.any((result) => result == null)) return; 73 if (_cascadeResults.values.any((result) => result == null)) return;
74 74
75 // Include all build errors for all cascades. If no cascades have 75 // Include all build errors for all cascades. If no cascades have
76 // errors, the result will automatically be considered a success. 76 // errors, the result will automatically be considered a success.
77 _resultsController.add(new BuildResult(flatten( 77 _resultsController.add(new BuildResult(unionAll(
78 _cascadeResults.values.map((result) => result.errors)))); 78 _cascadeResults.values.map((result) => result.errors))));
79 }, onError: _resultsController.addError); 79 }, onError: _resultsController.addError);
80 } 80 }
81 81
82 _errors = mergeStreams(_cascades.values.map((cascade) => cascade.errors)); 82 _errors = mergeStreams(_cascades.values.map((cascade) => cascade.errors));
83 } 83 }
84 84
85 /// Gets the asset node identified by [id]. 85 /// Gets the asset node identified by [id].
86 /// 86 ///
87 /// If [id] is for a generated or transformed asset, this will wait until it 87 /// If [id] is for a generated or transformed asset, this will wait until it
(...skipping 22 matching lines...) Expand all
110 /// Removes [removed] from the graph's known set of source assets. 110 /// Removes [removed] from the graph's known set of source assets.
111 void removeSources(Iterable<AssetId> sources) { 111 void removeSources(Iterable<AssetId> sources) {
112 groupBy(sources, (id) => id.package).forEach((package, ids) { 112 groupBy(sources, (id) => id.package).forEach((package, ids) {
113 var cascade = _cascades[package]; 113 var cascade = _cascades[package];
114 if (cascade == null) throw new ArgumentError("Unknown package $package."); 114 if (cascade == null) throw new ArgumentError("Unknown package $package.");
115 _cascadeResults[package] = null; 115 _cascadeResults[package] = null;
116 cascade.removeSources(ids); 116 cascade.removeSources(ids);
117 }); 117 });
118 } 118 }
119 } 119 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/errors.dart ('k') | pkg/barback/lib/src/phase.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698