Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-62523

Strange try .. catch behaviour when throwing exception

    XMLWordPrintable

Details

    Description

              function test()
              {
                  var exceptionCaught = false;
      
                  try
                  {
                    console.log("try");
                  }
                  catch(e)
                  {
                    console.log("catch " + e);
                    exceptionCaught = true;
                  }
      
                  if(!exceptionCaught)
                    throw "exception thrown outside above try scope";
                  else
                    console.log("executed again?!");
              }
      

      If I call this function I get the following output:

      qml: try
      qml: catch exception thrown outside above try scope
      qml: executed again?!
      

      Unless I'm missing some JavaScript subtlety, this seems somewhat wrong. It appears as if the try scope is extending over the whole function, and the "program counter" is getting moved back to the catch block and the code outside the try..catch is being re-executed?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            shausman Simon Hausmann
            timangus Tim Angus
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes