82e3a751a9
The frontend is now run with sound null safety so these are no longer needed. TEST=existing Change-Id: I6c1776845854695ff34e310a3bb5bc9d86715f06 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307901 Reviewed-by: Jens Johansen <jensj@google.com> Reviewed-by: Srujan Gaddam <srujzs@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
30 lines
741 B
Dart
30 lines
741 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;
|
|
|
|
import 'log.dart';
|
|
|
|
Future<T?> withErrorHandling<T>(Future<T> Function() f,
|
|
{Logger? logger}) async {
|
|
final ReceivePort port = ReceivePort();
|
|
try {
|
|
return await f();
|
|
} catch (e, trace) {
|
|
exitCode = 1;
|
|
stderr.writeln(e);
|
|
stderr.writeln(trace);
|
|
logger?.noticeFrameworkCatchError(e, trace);
|
|
return null;
|
|
} finally {
|
|
port.close();
|
|
}
|
|
}
|