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
How to use TryCatch properly?
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
  7 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
 
Stephan Beal  
View profile  
 More options Jul 20 2011, 10:27 pm
From: Stephan Beal <sgb...@googlemail.com>
Date: Thu, 21 Jul 2011 04:27:13 +0200
Local: Wed, Jul 20 2011 10:27 pm
Subject: How to use TryCatch properly?

Hello, v8 gurus,

       v8::TryCatch tryCatch;
        tryCatch.SetVerbose(true);
        tryCatch.SetCaptureMessage(true);
        v8::ThrowException(v8::String::New("CATCH THIS, DAMMIT!"));
        assert( tryCatch.HasCaught() );
        assert( !tryCatch.Exception().IsEmpty() );

i can't for the life of me figure out how to use TryCatch properly. Both of
those assertions fail (well, whichever one is enabled fails).

What am i missing here?

:-?

--
----- stephan beal
http://wanderinghorse.net/home/stephan/


 
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.
Mads Sig Ager  
View profile  
 More options Jul 21 2011, 3:08 am
From: Mads Sig Ager <a...@chromium.org>
Date: Thu, 21 Jul 2011 09:08:11 +0200
Local: Thurs, Jul 21 2011 3:08 am
Subject: Re: [v8-users] How to use TryCatch properly?

v8::ThrowException schedules an exception to be thrown when returning to
JavaScript. At the point where you ask if it has been caught it has not been
thrown yet.

Cheers,    -- Mads


 
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.
Stephan Beal  
View profile  
 More options Jul 21 2011, 3:11 am
From: Stephan Beal <sgb...@googlemail.com>
Date: Thu, 21 Jul 2011 09:11:31 +0200
Local: Thurs, Jul 21 2011 3:11 am
Subject: Re: [v8-users] How to use TryCatch properly?

On Thu, Jul 21, 2011 at 9:08 AM, Mads Sig Ager <a...@chromium.org> wrote:

> v8::ThrowException schedules an exception to be thrown when returning to
> JavaScript. At the point where you ask if it has been caught it has not been
> thrown yet.

i see. Thank you for that clarification.

The return value of ThrowException(): is it Undefined() or an Empty handle?
i recall (perhaps incorrectly) reading both descriptions over the years.

--
----- stephan beal
http://wanderinghorse.net/home/stephan/


 
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.
Mads Sig Ager  
View profile  
 More options Jul 21 2011, 4:16 am
From: Mads Sig Ager <a...@chromium.org>
Date: Thu, 21 Jul 2011 10:16:43 +0200
Local: Thurs, Jul 21 2011 4:16 am
Subject: Re: [v8-users] How to use TryCatch properly?

On Thu, Jul 21, 2011 at 9:11 AM, Stephan Beal <sgb...@googlemail.com> wrote:
> On Thu, Jul 21, 2011 at 9:08 AM, Mads Sig Ager <a...@chromium.org> wrote:

>> v8::ThrowException schedules an exception to be thrown when returning to
>> JavaScript. At the point where you ask if it has been caught it has not been
>> thrown yet.

> i see. Thank you for that clarification.

> The return value of ThrowException(): is it Undefined() or an Empty handle?
> i recall (perhaps incorrectly) reading both descriptions over the years.

It is undefined.

It *can* return an empty handle, but only if calling into V8 before it is
initialized or after it is dead (after an out of memory or similar).

Cheers,    -- Mads


 
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.
Stephan Beal  
View profile  
 More options Jul 21 2011, 4:21 am
From: Stephan Beal <sgb...@googlemail.com>
Date: Thu, 21 Jul 2011 10:21:06 +0200
Local: Thurs, Jul 21 2011 4:21 am
Subject: Re: [v8-users] How to use TryCatch properly?

On Thu, Jul 21, 2011 at 9:08 AM, Mads Sig Ager <a...@chromium.org> wrote:

> v8::ThrowException schedules an exception to be thrown when returning to
> JavaScript. At the point where you ask if it has been caught it has not been
> thrown yet.

A slight clarification: does "returning to JS" mean returning to a higher
scope than the TryCatch, or calling back into v8 (perhaps in a deeper scope
than the TryCatch, where the TC is still alive)?

--
----- stephan beal
http://wanderinghorse.net/home/stephan/


 
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.
Mads Sig Ager  
View profile  
 More options Jul 21 2011, 4:36 am
From: Mads Sig Ager <a...@chromium.org>
Date: Thu, 21 Jul 2011 10:36:41 +0200
Local: Thurs, Jul 21 2011 4:36 am
Subject: Re: [v8-users] How to use TryCatch properly?

On Thu, Jul 21, 2011 at 10:21 AM, Stephan Beal <sgb...@googlemail.com>wrote:

> On Thu, Jul 21, 2011 at 9:08 AM, Mads Sig Ager <a...@chromium.org> wrote:

>> v8::ThrowException schedules an exception to be thrown when returning to
>> JavaScript. At the point where you ask if it has been caught it has not been
>> thrown yet.

> A slight clarification: does "returning to JS" mean returning to a higher
> scope than the TryCatch, or calling back into v8 (perhaps in a deeper scope
> than the TryCatch, where the TC is still alive)?

It means actually returning to a JavaScript activation on the stack.
Returning to other C++ code will not throw the exception.

-- Mads


 
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.
Stephan Beal  
View profile  
 More options Jul 21 2011, 4:38 am
From: Stephan Beal <sgb...@googlemail.com>
Date: Thu, 21 Jul 2011 10:38:26 +0200
Local: Thurs, Jul 21 2011 4:38 am
Subject: Re: [v8-users] How to use TryCatch properly?

On Thu, Jul 21, 2011 at 10:36 AM, Mads Sig Ager <a...@chromium.org> wrote:

> It means actually returning to a JavaScript activation on the stack.
> Returning to other C++ code will not throw the exception.

Okay, that explains my code's broken behaviour. Thank you :).

--
----- stephan beal
http://wanderinghorse.net/home/stephan/


 
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 »