Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Unified Diff: runtime/vm/isolate.cc

Issue 1286163002: Make uncaught errors terminating isolates only get printed if nobody is listening. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/isolate.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/isolate.cc
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index e0f8752c1d1ec4c1c163e4bcfd46bf6fec605b11..f4744ff7230ffe8880eec58ed06303a30e8b1d09 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -569,10 +569,16 @@ bool IsolateMessageHandler::ProcessUnhandledException(const Error& result) {
} else {
exc_str = String::New(result.ToErrorCString());
}
- I->NotifyErrorListeners(exc_str, stacktrace_str);
+ bool has_listener = I->NotifyErrorListeners(exc_str, stacktrace_str);
if (I->ErrorsFatal()) {
- I->object_store()->set_sticky_error(result);
+ if (has_listener) {
+ const String& msg = String::Handle(String::New("isolate terminated"));
+ const UnwindError& error = UnwindError::Handle(UnwindError::New(msg));
+ I->object_store()->set_sticky_error(error);
Ivan Posva 2015/08/14 05:18:30 If we have notified the listener, then we can just
+ } else {
+ I->object_store()->set_sticky_error(result);
+ }
return false;
}
return true;
@@ -1203,11 +1209,11 @@ void Isolate::RemoveErrorListener(const SendPort& listener) {
}
-void Isolate::NotifyErrorListeners(const String& msg,
+bool Isolate::NotifyErrorListeners(const String& msg,
const String& stacktrace) {
const GrowableObjectArray& listeners = GrowableObjectArray::Handle(
this, this->object_store()->error_listeners());
- if (listeners.IsNull()) return;
+ if (listeners.IsNull()) return false;
const Array& arr = Array::Handle(this, Array::New(2));
arr.SetAt(0, msg);
@@ -1224,6 +1230,7 @@ void Isolate::NotifyErrorListeners(const String& msg,
PortMap::PostMessage(msg);
}
}
+ return listeners.Length() > 0;
}
« no previous file with comments | « runtime/vm/isolate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698