V8 exceptions

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

V8 exceptions

Postby lkitrossky » Fri May 08, 2015 5:52 am

Hi! I am calling from JavaScript in renderer to C++ commands in Execute(name, object, argument, retval, exception) method of CefV8Handler, and return back results via retval = with return true;
Things work, but from time to time some exception is thrown and I cannot catch it.
I tried to put try/catch(e) in JavaScript, it arrives to catch black, but with empty error e and no retval.
I tried to put try/catch black also into Cef C++ code, but ninja run results in warning C4530: "C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc", where I to put this key?
I tried also to put something into exception argument of Execute, but it does not arrive to JavaScript.
What I am doing wrong and how to treat exceptions correctly? Thanks, Levi
lkitrossky
Mentor
 
Posts: 66
Joined: Tue Mar 24, 2015 7:26 am

Re: V8 exceptions

Postby magreenblatt » Fri May 08, 2015 11:45 am

If you populate the |exception| value in CefV8Handler::Execute it should return the exception to JavaScript.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: V8 exceptions

Postby lkitrossky » Sun May 10, 2015 1:07 am

What to add into GYP file that will result in key /EHsc in MS Visual Studio project, please? Without it I cannot use try/catch in C++ properly. Thanks, Levi
I think I found it on
https://github.com/TooTallNate/node-gyp/issues/26, inside GYP:
Code: Select all
'VCCLCompilerTool':
        {
            'RuntimeLibrary': 3, # shared debug
            'ExceptionHandling': 1,     # /EHsc  doesn't work.
            '/EHsc' # Enable unwind semantics for Exception Handling.  This one actually does the trick
            # this is also where you can put /GR or /MDd, or other defines.
        }

There is a warning that '/EHsc' is invalid literal for int.
The process succeeded with
Code: Select all
'VCCLCompilerTool':
        {
            'RuntimeLibrary': 3, # shared debug
            'ExceptionHandling': 2,
        }
lkitrossky
Mentor
 
Posts: 66
Joined: Tue Mar 24, 2015 7:26 am

Re: V8 exceptions

Postby magreenblatt » Mon May 11, 2015 8:58 am

lkitrossky wrote:What to add into GYP file that will result in key /EHsc in MS Visual Studio project, please? Without it I cannot use try/catch in C++ properly.

You will not be able to use C++ try/catch in CEF/Chromium code. You can enable it in your application by modifying the libcef_dll_wrapper target settings to match your application settings.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 99 guests

cron