aeb2581f30
Closes https://github.com/dart-lang/sdk/issues/50438 TEST=tests/lib/isolate/handle_error_stacktrace_test, tests/lib/isolate/handle_exiting_to_string_error_test, tests/lib/isolate/handle_throwing_to_string_error_test Change-Id: I098153ecd65360aa724e25fc52e25368ca27ffe7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277341 Reviewed-by: Alexander Aprelev <aam@google.com> Reviewed-by: Derek Xu <derekx@google.com>
42 lines
1.0 KiB
Dart
42 lines
1.0 KiB
Dart
// Copyright (c) 2024, 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.
|
|
|
|
library handle_error_stacktrace_test;
|
|
|
|
import "dart:isolate";
|
|
|
|
import "package:expect/expect.dart";
|
|
import "package:async_helper/async_helper.dart";
|
|
|
|
const errorValue = "TEST_ERROR";
|
|
const stackTraceValue = "TEST_STACKTRACE";
|
|
|
|
void isolateMain() {
|
|
Error.throwWithStackTrace(errorValue, StackTrace.fromString(stackTraceValue));
|
|
}
|
|
|
|
void main() async {
|
|
asyncStart();
|
|
|
|
var receivedErrors = 0;
|
|
final errorPort = ReceivePort();
|
|
errorPort.listen((errorAndStack) {
|
|
Expect.listEquals([errorValue, stackTraceValue], errorAndStack);
|
|
receivedErrors++;
|
|
|
|
if (receivedErrors == 2) {
|
|
errorPort.close();
|
|
asyncEnd();
|
|
}
|
|
});
|
|
|
|
Isolate.spawn((_) => isolateMain(), null, onError: errorPort.sendPort);
|
|
Isolate.spawn(
|
|
(_) => isolateMain(),
|
|
null,
|
|
onError: errorPort.sendPort,
|
|
errorsAreFatal: false,
|
|
);
|
|
}
|