2d46ebd6a5
Fix all the Dart 2 runtime errors revealed by compiling dart2js, the front end itself, the front end tests. Change-Id: Ic6e6dd9f85db845b6a351ebbcfea9a6045843fc2 Reviewed-on: https://dart-review.googlesource.com/56322 Commit-Queue: Kevin Millikin <kmillikin@google.com> Reviewed-by: Aske Simon Christensen <askesc@google.com> Reviewed-by: Peter von der Ahé <ahe@google.com>
28 lines
677 B
Dart
28 lines
677 B
Dart
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE.md file.
|
|
|
|
library testing.error_handling;
|
|
|
|
import 'dart:async' show Future;
|
|
|
|
import 'dart:io' show exitCode, stderr;
|
|
|
|
import 'dart:isolate' show ReceivePort;
|
|
|
|
Future<T> withErrorHandling<T>(Future<T> f()) async {
|
|
final ReceivePort port = new ReceivePort();
|
|
try {
|
|
return await f();
|
|
} catch (e, trace) {
|
|
exitCode = 1;
|
|
stderr.writeln(e);
|
|
if (trace != null) {
|
|
stderr.writeln(trace);
|
|
}
|
|
return null;
|
|
} finally {
|
|
port.close();
|
|
}
|
|
}
|