Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How can I intentionally create a script error?

Hi,

If a certain condition is not true, I would like to intentionally fail the script execution. (I need to send an email regarding this condition from the server and not through a front - end alert..) I am having trouble devising an algorithm which fails only under this condition. Any syntax errors will fail always.

Ideally there would be something in my script like: if( MyConditionIsFalse, SCRIPT FAILS HERE, Script does not fail here)

Thoughts? Thanks!

Scott

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi,

Something like this maybe?

Table:

LOAD * INLINE [

F1, F2

A1, B1

A2, B2

A3, B3

];

LET vScriptStatus = NoOfRows('Table');

// Your condition here

IF $(vScriptStatus) > 1 THEN

     SET ErrorMode = 2;

     LET vErrorCode = $(=o); // I know this casuses an internal error

     EXIT SCRIPT;

END IF

Hope it helps

Miguel

View solution in original post

6 Replies
Miguel_Angel_Baeyens

Hello Scott,

You can use at any time

EXIT SCRIPT;


I'd set a variable and depending on the conditions you want, check in the script from time to time the variable. If the variable is equal to 1, then exit script, otherwise, keep executing the script.

Hope that helps!

Not applicable
Author

I am aware of the exit script command, but that will stop the script without producing an error. I am wondering if there is a way to have the script execution "fail", not just quit.

(Side note, how would you put that exit script command in the middle of an if statement?)

Miguel_Angel_Baeyens

Hi,

Something like this maybe?

Table:

LOAD * INLINE [

F1, F2

A1, B1

A2, B2

A3, B3

];

LET vScriptStatus = NoOfRows('Table');

// Your condition here

IF $(vScriptStatus) > 1 THEN

     SET ErrorMode = 2;

     LET vErrorCode = $(=o); // I know this casuses an internal error

     EXIT SCRIPT;

END IF

Hope it helps

Miguel

Not applicable
Author

Miguel,that $(=0) line worked great. You're the man.

Thanks,

Scott

Miguel_Angel_Baeyens

Thanks Scott.

I've set that on purpose, but any other syntax error would result on the script failing, too

XET vErrorCode = 1; // XET doesn't exists in QlikView


The hard part here is to set the condition, making the script to fail is quite the simple part, in my view.

Regards.

annacastan
Contributor II
Contributor II

Thanks @Miguel_Angel_Baeyens  your solution works. The other solution that is proposed above with the new updates doesn´t work propertly. 

 

XET vErrorCode = $(=o);