On 7 April 2015 at 17:31, Joerg Bornemann
<joerg.bornem...@theqtcompany.com> wrote:
>
> On 07-Apr-15 09:59, Dominique Fober wrote:
>
> > I'm using the new QJSEngine and I'm trying to get the error line number (in 
> > case of error of course).
> > Currently I'm handling errors as documented:
> >
> >       if (result.isError()) result.toString().toUtf8() ...
> >
> > but actually, the string is very poor: e.g. "SyntaxError: Syntax error"
> > I would like to get at least a line number. Contextual information would be 
> > also welcome.
> > Is it possible with the QJSEngine? (I'm using Qt 5.3.0)
>
> Try to access the properties "message", "fileName" and "lineNumber".
>
> if (result.isError())
>      qDebug() << result.property("fileName").toString();

Ooh, this is news to me.

I think we should document this somewhere, if it isn't already done (I
searched but couldn't find anything). I'm happy to volunteer if
necessary. Could you please provide a list of built-in properties of
various QJSValue types?

Also, what do you think of some API that returns a list of available
properties? (similar to QObject::dynamicPropertyNames() )


> result is a JavaScript Error object iff isError returns true.


Regards,
Sze-Howe
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to