| 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 7869913ae7b2ade37f4be09a24e6dfb852bf0bef..84e53131092dfe165d3c99944e1ca3e1662294f6 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/dart2js.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/dart2js.dart
|
| @@ -418,9 +418,9 @@ Future compile(List<String> argv) {
|
| return new EventSinkWrapper(writeStringSync, onDone);
|
| }
|
|
|
| - return api.compile(uri, libraryRoot, packageRoot,
|
| - inputProvider, diagnosticHandler,
|
| - options, outputProvider, environment)
|
| + return compileFunc(uri, libraryRoot, packageRoot,
|
| + inputProvider, diagnosticHandler,
|
| + options, outputProvider, environment)
|
| .then(compilationDone);
|
| }
|
|
|
| @@ -458,7 +458,7 @@ void fail(String message) {
|
| } else {
|
| print(message);
|
| }
|
| - exit(1);
|
| + exitFunc(1);
|
| }
|
|
|
| Future compilerMain(List<String> arguments) {
|
| @@ -592,7 +592,7 @@ void helpAndExit(bool wantHelp, bool wantVersion, bool verbose) {
|
| help();
|
| }
|
| }
|
| - exit(0);
|
| + exitFunc(0);
|
| }
|
|
|
| void helpAndFail(String message) {
|
| @@ -602,7 +602,14 @@ void helpAndFail(String message) {
|
| }
|
|
|
| void main(List<String> arguments) {
|
| - runZoned(() => compilerMain(arguments), onError: (exception, trace) {
|
| + internalMain(arguments);
|
| +}
|
| +
|
| +var exitFunc = exit;
|
| +var compileFunc = api.compile;
|
| +
|
| +Future internalMain(List<String> arguments) {
|
| + onError(exception, trace) {
|
| try {
|
| print('Internal error: $exception');
|
| } catch (ignored) {
|
| @@ -614,7 +621,14 @@ void main(List<String> arguments) {
|
| print(trace);
|
| }
|
| } finally {
|
| - exit(253); // 253 is recognized as a crash by our test scripts.
|
| + exitFunc(253); // 253 is recognized as a crash by our test scripts.
|
| }
|
| - });
|
| + }
|
| +
|
| + try {
|
| + return compilerMain(arguments).catchError(onError);
|
| + } catch (exception, trace) {
|
| + onError(exception, trace);
|
| + return new Future.value();
|
| + }
|
| }
|
|
|