I have a utility routine that I want to call from various v8 bindings. This
utility routine does some validation on the passed-in v8::value, and if it
doesn't match certain criteria, throws an exception. I'd like the callers to
be able to tell if the utility routine threw an exception or not, so they
can abort the current operation and cascade the exception up to the caller.
I thought the following code would work:
v8::TryCatch tryCatch;
fillWebCoreMessagePortArray(args[1], portArray);
if (tryCatch.HasCaught())
return throwError(tryCatch.Exception());
However, even though fillWebCoreMessagePortArray() calls
V8Proxy::throwError() to generate an exception, and the calling JS code sees
the exception, HasCaught() in the code above returns false. As far as I can
tell, it's because invoking throwError() just sets a pending_exception in
thread_local data, which is then converted into a real exception only under
certain circumstances which apparently I'm not meeting.
I could change fillWebCoreMessagePortArray() to return a boolean denoting
whether an error has occurred rather than trying to catch the error in the
calling code - that might be a cleaner solution. Or perhaps there's
something I should be doing to make Top::ReportPendingMessages() get invoked
to actually cause the generated exception to no longer be "pending"? What's
the preferred approach in cases like this?
-atw
--~--~---------~--~----~------------~-------~--~----~
Chromium Developers mailing list: [email protected]
View archives, change email options, or unsubscribe:
http://groups.google.com/group/chromium-dev
-~----------~----~----~----~------~----~------~--~---