[Development] Javascript exceptions from QML plugin
Alan Alpert
416365416c at gmail.com
Tue Nov 19 18:14:05 CET 2013
On Sat, Nov 16, 2013 at 7:15 AM, Pattyn, Kurt <kurt.pattyn at barco.com> wrote:
> Hi,
>
> is there a way to emit Javascript exceptions from a C++ QML plugin or more general: what is the best way to indicate errors to QML from within a QML plugin?
> The reason I ask, is because I am implementing the W3C WebSocket API (see http://www.w3.org/TR/websockets).
> In several circumstances, the standard says to throw javascript exceptions.
> Maybe an elegant solution could be to just expose an exception signal, and use that instead.
JS Exceptions would be nice, at least in this case for spec
compliance. However I don't think you can currently do that in
QJSEngine, another one of those limitations we'd like to fix in the
long term.
For now I recommend having an "Error" status and an invokable function
to get the error string (or a string property), just like
QQmlComponent. That works well with QML, even though it does diverge
from the WebSocket spec.
--
Alan Alpert
More information about the Development
mailing list