-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Exceptions from Future do not contain original call site #8656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
(not sure how to triage, starting with VM as first guess) |
Marked as being merged into #7040. |
Something like this could be done to get more context about the original call site: import 'dart:async'; String getCurrentStackTrace() { Future doItLater() { main() { Executing this I get: Unhandled exception: #0 _FutureImpl._scheduleUnhandledError.<anonymous closure> (dart:async:348:9) |
Hi Siva, How does this work when you can't edit doItLater? That is, you don't own it and it's a 3rd party library. (I understand that all Dart apps are just text files, but it's not good practice to start editing dependencies.) Also, doesn't this assume I know where the exception is happening in the first place? If I knew that, I wouldn't have to add the special getCurrentStackTrace() function. :) Thoughts? Thanks! |
For the more generic case that you describe one would have to implement a subclass of Future which would have the additional functionality of storing the stack trace for later use. I think a mechanism like that is outside the scope of the Dart VM. |
Thanks Siva, I'll ask the lib team about this. |
Consider this code:
import 'dart:async';
Future doItLater() {
//return new Future.immediate('dart');
return new Future.immediateError(new StateError('doh!'));
}
main() {
doItLater().then(print);
}
When you run it, you get:
sethladd:~/dart/simpletests/bin$ dart asyncexception.dart
Uncaught Error: Bad state: doh!
Unhandled exception:
Bad state: doh!
0 _FutureImpl._scheduleUnhandledError.<anonymous closure> (dart:async:334:9)
1 Timer.Timer.<anonymous closure> (dart:async-patch:11:15)
2 _Timer._createTimerHandler._handleTimeout (dart:io:7240:28)
3 _Timer._createTimerHandler._handleTimeout (dart:io:7248:7)
4 _Timer._createTimerHandler.<anonymous closure> (dart:io:7256:23)
5 _ReceivePortImpl._handleMessage (dart:isolate-patch:40:92)
Problem:
The stack trace does not include any reference to the line of code that actually generated the error.
This makes debugging Dart really difficult.
(submitted on behalf of a partner who is building a Dart app for his job)
The text was updated successfully, but these errors were encountered: