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

Unified Diff: runtime/vm/exceptions.cc

Issue 11413101: Added support for isolate unhandled exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed test status Created 8 years, 1 month 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
Index: runtime/vm/exceptions.cc
diff --git a/runtime/vm/exceptions.cc b/runtime/vm/exceptions.cc
index 479ad64437e836f83aa2a82f8492a484359eebfb..fc7fc5e254fa5d9217f48c59ed3e5dff363e62bc 100644
--- a/runtime/vm/exceptions.cc
+++ b/runtime/vm/exceptions.cc
@@ -4,6 +4,7 @@
#include "vm/exceptions.h"
+#include "vm/dart_api_impl.h"
#include "vm/dart_entry.h"
#include "vm/debugger.h"
#include "vm/flags.h"
@@ -163,14 +164,20 @@ static void ThrowExceptionHelper(const Instance& incoming_exception,
pc_offset_list);
if (handler_pc == 0) {
// There are no dart invocation frames on the stack so we do not
- // have a caller to return to. This is a case where we would have
- // to call the Isolate error handler and let it deal with the shutdown.
- // We report an error and shutdown the process as a temporary solution
- // until the isolate error handler stuff is implemented.
+ // have a caller to return to.
ASSERT(!handler_exists);
- OS::PrintErr("Exception '%s' thrown:\n", exception.ToCString());
- OS::PrintErr("Exiting the process\n");
- OS::Exit(255);
+ if (Isolate::UnhandledExceptionCallback() != NULL) {
+ // Notify embedder that an unhandled exception occurred.
+ Dart_EnterScope();
+ Dart_Handle error_handle = Api::NewHandle(Isolate::Current(),
+ incoming_exception.raw());
+ (Isolate::UnhandledExceptionCallback())(error_handle);
+ Dart_ExitScope();
+ } else {
+ OS::PrintErr("Exception '%s' thrown:\n", exception.ToCString());
+ OS::PrintErr("Exiting the process\n");
siva 2012/11/26 23:03:02 The comment "Exiting the process" is not valid any
Tom Ball 2012/11/26 23:14:50 Done.
Tom Ball 2012/11/26 23:14:50 Done.
+ }
+ Dart_ShutdownIsolate();
}
// TODO(5411263): At some point we can optimize by figuring out if a
// stack trace is needed based on whether the catch code specifies a

Powered by Google App Engine
This is Rietveld 408576698