How to detect exception when executing Javascript in NPAPI plugin?
Posted
by
Jordfräs
on Stack Overflow
See other posts from Stack Overflow
or by Jordfräs
Published on 2011-03-04T09:33:04Z
Indexed on
2011/03/04
15:25 UTC
Read the original article
Hit count: 250
npapi
In a plug-in I am using NPN_Evaluate() to execute some Javascript. How can I detect wether the Javascript raises an exception? Basically I want to execute any piece of Javascript and get the result from it or detect if it raised an exception.
I tried wrapping my Javascript code like this:
try {
// Injected Javascript code here
}
catch (exc) {
exc;
}
That way the result from NPN_Evaluate() will be an NPObject* containing a property "message" with the exception message if something goes wrong. But how can I know that it is an exception? It might as well be a result from the injected Javascript code.
Am I approaching this the wrong way? Can I detect an exception without catching it in Javascript and returning the exception as the result?
© Stack Overflow or respective owner