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: lib/src/barback/transformer_isolate.dart

Issue 1668983003: Support the new isolate load error messages. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | test/transformer/fails_to_load_a_transform_with_an_import_error_test.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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:isolate'; 7 import 'dart:isolate';
8 8
9 import 'package:barback/barback.dart'; 9 import 'package:barback/barback.dart';
10 import 'package:source_span/source_span.dart'; 10 import 'package:source_span/source_span.dart';
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (error.type != 'IsolateSpawnException') throw error; 84 if (error.type != 'IsolateSpawnException') throw error;
85 85
86 // TODO(nweiz): don't parse this as a string once issues 12617 and 12689 86 // TODO(nweiz): don't parse this as a string once issues 12617 and 12689
87 // are fixed. 87 // are fixed.
88 var firstErrorLine = error.message.split('\n')[1]; 88 var firstErrorLine = error.message.split('\n')[1];
89 89
90 // The isolate error message contains the fully expanded path, not the 90 // The isolate error message contains the fully expanded path, not the
91 // "package:" URI, so we have to be liberal in what we look for in the 91 // "package:" URI, so we have to be liberal in what we look for in the
92 // error message. 92 // error message.
93 var missingTransformer = idsToUrls.keys.firstWhere((id) => 93 var missingTransformer = idsToUrls.keys.firstWhere((id) =>
94 firstErrorLine.startsWith( 94 firstErrorLine.startsWith('Could not import "${idsToUrls[id]}"'),
95 "Load Error for") &&
96 firstErrorLine.contains(idsToUrls[id].path),
97 orElse: () => throw error); 95 orElse: () => throw error);
98 var packageUri = idToPackageUri(idsToAssetIds[missingTransformer]); 96 var packageUri = idToPackageUri(idsToAssetIds[missingTransformer]);
99 97
100 // If there was an IsolateSpawnException and the import that actually 98 // If there was an IsolateSpawnException and the import that actually
101 // failed was the one we were loading transformers from, throw an 99 // failed was the one we were loading transformers from, throw an
102 // application exception with a more user-friendly message. 100 // application exception with a more user-friendly message.
103 fail('Transformer library "$packageUri" not found.', 101 fail('Transformer library "$packageUri" not found.',
104 error, stackTrace); 102 error, stackTrace);
105 }); 103 });
106 }); 104 });
(...skipping 26 matching lines...) Expand all
133 /// An error thrown when a transformer fails to load. 131 /// An error thrown when a transformer fails to load.
134 class TransformerLoadError extends SourceSpanException 132 class TransformerLoadError extends SourceSpanException
135 implements WrappedException { 133 implements WrappedException {
136 final CrossIsolateException innerError; 134 final CrossIsolateException innerError;
137 Chain get innerChain => innerError.stackTrace; 135 Chain get innerChain => innerError.stackTrace;
138 136
139 TransformerLoadError(CrossIsolateException error, SourceSpan span) 137 TransformerLoadError(CrossIsolateException error, SourceSpan span)
140 : innerError = error, 138 : innerError = error,
141 super("Error loading transformer: ${error.message}", span); 139 super("Error loading transformer: ${error.message}", span);
142 } 140 }
OLDNEW
« no previous file with comments | « no previous file | test/transformer/fails_to_load_a_transform_with_an_import_error_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698