blob: 872f2f0ca8417c6e32f72f261bef613a1c5c0b02 [file] [log] [blame]
// 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 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> f(), {Logger? logger}) async {
final ReceivePort port = new ReceivePort();
try {
return await f();
} catch (e, trace) {
exitCode = 1;
// ignore: unnecessary_null_comparison
if (trace != null) {
logger?.noticeFrameworkCatchError(e, trace);
return null;
} finally {