I'm trying to add errors thrown from my cpp objects exposed to JS.
Here's an example
@JSObject::JSObject(QWebFrame *p_frame, QObject *parent) :
frame = p_frame;
//logic here, let's assume something went wrong
qDebug("test method called, emmiting signal");
qDebug("emit finished, method returning now");
return "method finish";
QString l_js ="alert('throwing error'); throw new Error();";
qDebug("throw error call finished");
and the html:
<title> Error throwing test</title>
var result = MyAPI.TestMethod(); //this should throw an error
The alert set here:
@QString l_js ="alert('throwing error'); throw new Error();"; @
happens when expected, i get this output:
test method called, emmiting signal
//alert happens here, untill i press ok there is no more output, execution stops and waits for alert window to close
throw error call finished
emit finished, method returning now
So I know throw error is executed at the right time, but something is wrong, JS try/catch does not catch it.
Anybody knows of a good way to add JS errors to exposed cpp objects?
I think you basically have the same problem as I do ("see here":http://developer.qt.nokia.com/forums/viewthread/6881/ ).
If perhaps you did find a solution in the meantime, then please let me know, thanks!