Index: sdk/lib/_internal/compiler/implementation/dart2js.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/dart2js.dart b/sdk/lib/_internal/compiler/implementation/dart2js.dart |
index 55812c0c6d932efd846d82de38cd91cafe254e7c..328c1d5e1af5126d9035d7edd6062aa62d817407 100644 |
--- a/sdk/lib/_internal/compiler/implementation/dart2js.dart |
+++ b/sdk/lib/_internal/compiler/implementation/dart2js.dart |
@@ -91,7 +91,7 @@ void parseCommandLine(List<OptionHandler> handlers, List<String> argv) { |
} |
} |
-void compile(List<String> argv) { |
+Future compile(List<String> argv) { |
bool isWindows = (Platform.operatingSystem == 'windows'); |
stackTraceFilePrefix = '$currentDirectory'; |
Uri libraryRoot = currentDirectory; |
@@ -388,10 +388,10 @@ void compile(List<String> argv) { |
return new EventSinkWrapper(writeStringSync, onDone); |
} |
- api.compile(uri, libraryRoot, packageRoot, |
+ return api.compile(uri, libraryRoot, packageRoot, |
inputProvider.readStringFromUri, handler, |
options, outputProvider) |
- .then(compilationDone); |
+ .then(compilationDone); |
} |
class EventSinkWrapper extends EventSink<String> { |
@@ -426,11 +426,11 @@ void fail(String message) { |
exit(1); |
} |
-void compilerMain(Options options) { |
+Future compilerMain(Options options) { |
var root = uriPathToNative("/$LIBRARY_ROOT"); |
List<String> argv = ['--library-root=${options.script}$root']; |
argv.addAll(options.arguments); |
- compile(argv); |
+ return compile(argv); |
} |
void help() { |
@@ -577,20 +577,22 @@ void helpAndFail(String message) { |
} |
void mainWithErrorHandler(Options options) { |
- try { |
- compilerMain(options); |
- } catch (exception, trace) { |
+ compilerMain(options).catchError((exception) { |
try { |
print('Internal error: $exception'); |
} catch (ignored) { |
print('Internal error: error while printing exception'); |
} |
+ |
try { |
- print(trace); |
+ var trace = getAttachedStackTrace(exception); |
+ if (trace != null) { |
+ print(trace); |
+ } |
} finally { |
exit(253); // 253 is recognized as a crash by our test scripts. |
} |
- } |
+ }); |
} |
void main() { |