Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Correctly handle uncaught exception objects. (issue 11365200)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
yang...@chromium.org  
View profile  
 More options Nov 12 2012, 12:29 pm
From: yang...@chromium.org
Date: Mon, 12 Nov 2012 17:29:06 +0000
Local: Mon, Nov 12 2012 12:29 pm
Subject: Correctly handle uncaught exception objects. (issue 11365200)
Reviewers: Jakob,

Description:
Correctly handle uncaught exception objects.

R=jkumme...@chromium.org
BUG=

Please review this at https://chromiumcodereview.appspot.com/11365200/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
   M src/isolate.cc
   M test/cctest/test-api.cc

Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index  
eec5a54d737e902caddfcfe5679dcb33656c8dd1..73a6310b4c084a8280e2d085cdc38521c f9be7b7  
100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1228,18 +1228,22 @@ void Isolate::DoThrow(Object* exception,  
MessageLocation* location) {
                stack_trace_for_uncaught_exceptions_options_);
          }
        }
-      // Stringify custom error objects for the message object.
+
+      Handle<Object> exception_arg = exception_handle;
+      // If the exception argument is a custom object, turn it into a  
string
+      // before throwing as uncaught exception.  Note that the pending
+      // exception object to be set later must not be turned into a string.
        if (exception_handle->IsJSObject()  
&& !IsErrorObject(exception_handle)) {
          bool failed = false;
-        exception_handle = Execution::ToString(exception_handle, &failed);
+        exception_arg = Execution::ToString(exception_arg, &failed);
          if (failed) {
-          exception_handle = factory()->LookupAsciiSymbol("exception");
+          exception_arg = factory()->LookupAsciiSymbol("exception");
          }
        }
        Handle<Object> message_obj = MessageHandler::MakeMessageObject(
            "uncaught_exception",
            location,
-          HandleVector<Object>(&exception_handle, 1),
+          HandleVector<Object>(&exception_arg, 1),
            stack_trace,
            stack_trace_object);
        thread_local_top()->pending_message_obj_ = *message_obj;
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index  
41eb68f231f24d1f5fdc9eff1211429e8efa206e..ec7379c468f7a31a01c46dfa311ad8e97 79bdcb0  
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -2554,6 +2554,18 @@ THREADED_TEST(ScriptException) {
  }

+TEST(TryCatchCustomException) {
+  v8::HandleScope scope;
+  LocalContext env;
+  v8::TryCatch try_catch;
+  CompileRun("function CustomError() { this.a = 'b'; }"
+             "(function f() { throw new CustomError(); })();");
+  CHECK(try_catch.HasCaught());
+  CHECK(try_catch.Exception()->ToObject()->
+            Get(v8_str("a"))->Equals(v8_str("b")));
+}
+
+
  bool message_received;


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jkumme...@chromium.org  
View profile  
 More options Nov 12 2012, 12:30 pm
From: jkumme...@chromium.org
Date: Mon, 12 Nov 2012 17:30:25 +0000
Local: Mon, Nov 12 2012 12:30 pm
Subject: Re: Correctly handle uncaught exception objects. (issue 11365200)
 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »