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 pub.transformer_isolate; | 5 library pub.transformer_isolate; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 .then((_) => port.first) | 76 .then((_) => port.first) |
77 .then((sendPort) { | 77 .then((sendPort) { |
78 return new TransformerIsolate._(sendPort, environment.mode, idsToUrls); | 78 return new TransformerIsolate._(sendPort, environment.mode, idsToUrls); |
79 }).catchError((error, stackTrace) { | 79 }).catchError((error, stackTrace) { |
80 if (error is! CrossIsolateException) throw error; | 80 if (error is! CrossIsolateException) throw error; |
81 if (error.type != 'IsolateSpawnException') throw error; | 81 if (error.type != 'IsolateSpawnException') throw error; |
82 | 82 |
83 // TODO(nweiz): don't parse this as a string once issues 12617 and 12689 | 83 // TODO(nweiz): don't parse this as a string once issues 12617 and 12689 |
84 // are fixed. | 84 // are fixed. |
85 var firstErrorLine = error.message.split('\n')[1]; | 85 var firstErrorLine = error.message.split('\n')[1]; |
86 var missingTransformer = idsToUrls.keys.firstWhere((id) => | 86 var missingTransformer = idsToUrls.keys.firstWhere( |
87 firstErrorLine.startsWith("Failure getting ${idsToUrls[id]}:"), | 87 (id) => firstErrorLine.startsWith( |
| 88 "Uncaught Error: Failure getting ${idsToUrls[id]}:"), |
88 orElse: () => throw error); | 89 orElse: () => throw error); |
89 var packageUri = idToPackageUri(idsToAssetIds[missingTransformer]); | 90 var packageUri = idToPackageUri(idsToAssetIds[missingTransformer]); |
90 | 91 |
91 // If there was an IsolateSpawnException and the import that actually | 92 // If there was an IsolateSpawnException and the import that actually |
92 // failed was the one we were loading transformers from, throw an | 93 // failed was the one we were loading transformers from, throw an |
93 // application exception with a more user-friendly message. | 94 // application exception with a more user-friendly message. |
94 fail('Transformer library "$packageUri" not found.', | 95 fail('Transformer library "$packageUri" not found.', |
95 error, stackTrace); | 96 error, stackTrace); |
96 }); | 97 }); |
97 }); | 98 }); |
(...skipping 26 matching lines...) Expand all Loading... |
124 /// An error thrown when a transformer fails to load. | 125 /// An error thrown when a transformer fails to load. |
125 class TransformerLoadError extends SourceSpanException | 126 class TransformerLoadError extends SourceSpanException |
126 implements WrappedException { | 127 implements WrappedException { |
127 final CrossIsolateException innerError; | 128 final CrossIsolateException innerError; |
128 Chain get innerChain => innerError.stackTrace; | 129 Chain get innerChain => innerError.stackTrace; |
129 | 130 |
130 TransformerLoadError(CrossIsolateException error, SourceSpan span) | 131 TransformerLoadError(CrossIsolateException error, SourceSpan span) |
131 : innerError = error, | 132 : innerError = error, |
132 super("Error loading transformer: ${error.message}", span); | 133 super("Error loading transformer: ${error.message}", span); |
133 } | 134 } |
OLD | NEW |