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

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: Incorporated code review feedback 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
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/exceptions.cc
diff --git a/runtime/vm/exceptions.cc b/runtime/vm/exceptions.cc
index 479ad64437e836f83aa2a82f8492a484359eebfb..ba1dae4cab67ea1d0ddb4139066cd06e4713c278 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("Shutting down the isolate\n");
+ }
+ 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
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698