blob: 28e9531593f7e3e498e8fd7f280eca7194bede3e [file] [log] [blame]
// Copyright (c) 2011, 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.
/// @assertion void handleUncaughtError(error, StackTrace stackTrace)
/// Handles uncaught asynchronous errors.
/// @description Checks that handleUncaughtError callback can be set via
/// ZoneSpecification and that correct callback is invoked.
/// @author ilya
import "dart:async";
import "../../../Utils/expect.dart";
int count = 0;
var stackTraces={};
HandleUncaughtErrorHandler newHandler() {
int id = ++count;
return (Zone self, ZoneDelegate parent, Zone zone, e, st) {
Expect.identical(id, e);
Expect.identical(stackTraces[id], st);
Zone newErrorZone (Zone z) =>
z.fork(specification: new ZoneSpecification(handleUncaughtError: newHandler()));
void test() {
try {
throw count; // i-th error should be caught by i-th handler
} catch (e, st) {
stackTraces[count] = st;
Zone.current.handleUncaughtError(e, st);
if (count < 10) {
main() {