1 Reply Latest reply: May 5, 2017 3:39 AM by Peter Cammaert RSS

    How to Get multiple errors with ScriptErrorDetails

    Jeric Mandis Ong

      Hi I'm currently creating a script that should catch the errors using ScriptErrorDetails (eg: Field Not Found). But when using ScriptErrorDetails it only gets the first error it catches. Is there a way to get all the errors in the load statement? For example multiple missing fields. My goal is to create a table that contains all the errors in my script. Below is my sample code.

       

      Set ErrorMode=0;  //would let qlik continue if there is an error

       

       

      Sample:

      LOAD Datesdsd, //Date (purposedly typed in an incorrect field)

      [Application ID]

          

      FROM

      [..\Documents\Working Hours Calendar.xlsx]

      (ooxml, embedded labels, table is [Sample Date]);

      Let vErrorDetails0 = ScriptErrorDetails; //just gets the 1st error

       

       

      Holidays:

      LOAD Holiday_Dtsda, //Holiday_Dt (purposedly typed in an incorrect field)

           Holiday_Type

      FROM

      [..\Documents\Working Hours Calendar.xlsx]

      (ooxml, embedded labels, table is Holidays);

      Let vErrorDetails1 = ScriptErrorDetails; //just gets the 1st error

       

       

      ERROR_TABLE:

      LOAD * INLINE

      [LOAD #, ERRORS

      LOAD 1, '$(vErrorDetails0)'

      LOAD 2, '$(vErrorDetails1)'];

       

       

      ERROR_TABLE1:

      LOAD [LOAD #] as LOAD_NO, ERRORS as ERROR

      RESIDENT ERROR_TABLE

      WHERE ERRORS <> '';

      //whows only errors

      //this table would be stored and will be populated incrementally

      DROP TABLE ERROR_TABLE;

        • Re: How to Get multiple errors with ScriptErrorDetails
          Peter Cammaert

          The LOAD script engine uses an interpreted language. IMHO upon encountering the first error, statement interpretation and/or execution will be aborted. If you have set ErrorMode to zero, the script engine will proceed to the next statement. Otherwise script execution will be aborted altogether.

           

          I think you can only capture one error per statement. However using some clever code, you can capture every first error in every statement. However since the first error in a particular statement (for example "Field Not Found") usually produces a cascade of more-or-less-irrelevant errors in subsequent statements (for example "Missing table"), that may not be very useful.