Make dart2js code retain the original stack trace for uncaught async errors.

R=sigmund@google.com

Review URL: https://codereview.chromium.org/1383213002 .
This commit is contained in:
Lasse R.H. Nielsen 2015-11-17 15:17:04 +01:00
parent aa16622d8d
commit 5363e5c945
3 changed files with 53 additions and 1 deletions

View file

@ -11,6 +11,7 @@ import 'dart:_js_helper' show
convertDartClosureToJS,
getTraceFromException,
requiresPreamble,
wrapException,
unwrapException;
import 'dart:_isolate_helper' show
IsolateNatives,
@ -518,5 +519,7 @@ class _SyncStarIterable extends IterableBase {
@patch
void _rethrow(Object error, StackTrace stackTrace) {
throw new AsyncError(error, stackTrace);
error = wrapException(error);
JS("void", "#.stack = #", error, stackTrace.toString());
JS("void", "throw #", error);
}

View file

@ -0,0 +1,46 @@
// 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 "dart:async";
import "dart:js";
import "dart:collection" show Queue;
import "package:expect/expect.dart";
import "package:async_helper/async_helper.dart";
var errors = new Queue();
int ctr = 0;
main() {
print("STARTED");
asyncStart();
void errorHandler(self, message, url, line, [column, error]) {
print(">> $message / $ctr");
var expect = errors.removeFirst();
if (ctr == 2) {
asyncEnd();
print("DONE");
}
Expect.equals(expect[0].toString(), message);
Expect.equals(expect[1].toString(), error["stack"].toString());
}
context["onerror"] = new JsFunction.withThis(errorHandler);
void throwit() {
var err = ++ctr;
try {
throw err;
} catch (e, s) {
errors.add([e, s]);
rethrow;
}
}
() async {
() async {
throwit();
}();
throwit();
}();
}

View file

@ -359,6 +359,9 @@ mirrors/mirrors_used_typedef_declaration_test/01: Crash # Assertion failure: typ
mirrors/mirrors_used_typedef_declaration_test/none: Crash # Assertion failure: typedef(Foo) has not been checked for cycles.
mirrors/typedef_library_test: Crash # Assertion failure: typedef(G) has not been checked for cycles.
[ $compiler != dart2js ]
async/dart2js_uncaught_error_test: Skip # JS-integration only test
[ $noopt ]
mirrors/*: SkipByDesign
convert/chunked_conversion_utf88_test: Pass, Timeout