Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QJSEngine and error line
Forum Updated to NodeBB v4.3 + New Features

QJSEngine and error line

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fober
    wrote on last edited by
    #1

    Hi,

    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)

    Dominique

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi Dominique,

      It looks to me like a missing feature in QJSEngine. The documentation mentions line numbers, but the API doesn't seem to provide a way to retrieve it.

      I might have missed something though. I suggest taking this to the Interest mailing list -- subscribe to the list and post your question there. Qt engineers are active on this list, and they will be able to tell you if there's currently a way to do what you want. (If not, you can submit a feature request)

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fober
        wrote on last edited by
        #3

        Thanks for the pointer to the list.
        I've got the answer:
        Try to access the properties "message", "fileName" and "lineNumber".
        if (result.isError())
        qDebug() << result.property("fileName").toString();
        result is a JavaScript Error object iff isError returns true.

        JKSHJ 1 Reply Last reply
        0
        • F fober

          Thanks for the pointer to the list.
          I've got the answer:
          Try to access the properties "message", "fileName" and "lineNumber".
          if (result.isError())
          qDebug() << result.property("fileName").toString();
          result is a JavaScript Error object iff isError returns true.

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          @fober
          Great! Thanks for sharing the answer.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved