mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:37:12 +00:00
8760283247
A combination of `runZoned` and `runZonedGuarded` where only the latter allows an `onError` parameter, and only that has a nullable return type. Retains the `onError` parameter on `runZoned` for now because it's too breaking to remove it until packages have been migrated off of it. It will be removed in a follow-up CL. Change-Id: If0e86c8d14e13fa089c66f4af975aeacb2616cf6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137302 Reviewed-by: Jake Macdonald <jakemac@google.com> Reviewed-by: Nate Bosch <nbosch@google.com>
27 lines
757 B
Dart
27 lines
757 B
Dart
// Copyright (c) 2013, 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 file.
|
|
|
|
import "package:expect/expect.dart";
|
|
import 'dart:async';
|
|
import 'package:async_helper/async_helper.dart';
|
|
|
|
main() {
|
|
asyncStart();
|
|
// Ensure that `runZoned`'s onError handles synchronous errors, and throwing
|
|
// in the error handler at that point (when it is a synchronous error) yields
|
|
// a synchronous error.
|
|
try {
|
|
runZonedGuarded(() {
|
|
throw 0;
|
|
}, (e, s) {
|
|
Expect.equals(0, e);
|
|
throw e; //#01 : ok
|
|
asyncEnd();
|
|
});
|
|
} catch (e) {
|
|
asyncEnd(); return; //# 01: continued
|
|
rethrow;
|
|
}
|
|
}
|