Uploaded image for project: 'JS - JobScheduler'
  1. JS - JobScheduler
  2. JS-1781

Improve JavaScript source code reference in error messages

    XMLWordPrintable

Details

    Description

      Current Situation
      Error messages for scripts implemented with JavaScript within the scope of jobs and monitors indicate the source code line for which an error occurred.

      1. Working Test Case: example for errors reported from a single included file
        • A given job is configured to include a JavaScript file like this:
          <job >
              <script  language="java:javascript">
                  <include  live_file="JavaScript-Include.js"/>
              </script>
          
              <run_time />
          </job>
          
        • The JavaScript file JavaScript-Include.js looks like this:
          function spooler_process()
          {
              spooler_log.info( "hello world" );
              this is an error
          
          	return true;
          }
          
        • The resulting error message accurately references line 4 as the source of error.
          COM-80020009 Ausnahmefehler aufgetreten. [begin] [] [Z-JAVA-105 Java exception java.lang.RuntimeException: javax.script.ScriptException: <eval>:4:9 Expected ; but found is
           this is an error
           ^ in <eval> at line number 4 at column number 9
          
      2. Failed Test Case: example for errors from a number of files included with the <script> element:
        • A given job is configured like this:
          job >
              <script  language="java:javascript">
                  <include  live_file="JavaScript-Include-First.js"/>
          
                  <include  live_file="JavaScript-Include.js"/>
              </script>
          
              <run_time />
          </job>
          
        • The JavaScript file JavaScript-Include.js looks like the example from Test Case 1.
        • The JavaScript file JavaScript-Include-First.js looks like this:
          // some comment
          
          var a = 1;
          var b = 2;
          
        • The resulting error message shows:
          COM-80020009 Ausnahmefehler aufgetreten. [begin] [] [Z-JAVA-105 Java exception java.lang.RuntimeException: javax.script.ScriptException: <eval>:7:9 Expected ; but found is
           this is an error
           ^ in <eval> at line number 7 at column number 9
          
        • The source code reference indicates line 7 being the source of the error when in fact this is line 4 of the file JavaScript-Include-First.js.
      3. Failed Test Case: example for errors included with <script> element:
        • A given job includes an error
          <job >
              <script  language="java:javascript">
                  <![CDATA[
          function spooler_process()
          {
              spooler_log.info( "hello world" );
              this is an error
          
              return true;
          }
                  ]]>
              </script>
          
              <run_time />
          </job>
          
        • The resulting error message shows:
          COM-80020009 Ausnahmefehler aufgetreten. [begin] [] [Z-JAVA-105 Java exception java.lang.RuntimeException: javax.script.ScriptException: <eval>:5:9 Expected ; but found is
           this is an error
           ^ in <eval> at line number 5 at column number 9
          
        • The source code reference indicates line 5 being the source of the error when in fact this is line 4.

      Desired Behavior

      • Test cases 2 and 3 should report the correct source code line number of the error. This should include to state the name of the file that caused the error.

      Attachments

        Activity

          People

            ap Andreas Püschel
            ap Andreas Püschel
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: