| 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 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |