Throw error in script

Post your questions and help other users.

Moderator: Martin

Post Reply
skahlhoefer
Posts: 12
Joined: 02 Dec 2013 22:35

Throw error in script

Post by skahlhoefer » 30 Aug 2014 07:55

Hi Martin,
I want to throw an error in a script sto abort its execution and don't execute following actions with unsufficient data.
I found the reserved words throw and throws which could be helpful but didn't gather any information in how to usw them.
Can you help?

If my intention is currently not supported this would be a feature request for a function like throw, abort or exit.

Thanks in advance and enjoy your weekend!
Stefan

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Throw error in script

Post by Martin » 30 Aug 2014 08:44

Hi,

Throw/throws are just reserved for future use but are currently not implemented in any way.
You could either use a condition Expression to check whether the required preconditions are met to execute the script at all or you could write the script in a way that does not execute some parts of the script when things are missing. You could also set a variable error=true and use this variable in the following actions/conditions to terminate the flow.

You could also force the script to run into an error by calling a function that does not exist, for example:

Code: Select all

a=1;
b=2;
error();
The first two lines of this script are executed but the third line terminates the script with an error since no function error exists.

Regards,
Martin

skahlhoefer
Posts: 12
Joined: 02 Dec 2013 22:35

Re: Throw error in script

Post by skahlhoefer » 30 Aug 2014 09:04

Hi Martin,

thanks for your fast reply. I knew the possibility to use a seperate expression but I found this too much overhead.
Your trick regarding the usw of a not existing function worked for the moment but is quiet dirty I think.

Could you move this thread to the feature requests for implementing a clean exit Funktion please?

Stefan

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Throw error in script

Post by Martin » 30 Aug 2014 09:36

Hi Stefan,

The last evaluated line of condition Expression is the one that determines whether the condition executes the flow on the true or false branch, so you could also write the entire script into condition Expression. Wouldn't it be cleaner to use such a mechanism to control the flow than to use an exception at all?

Regards,
Martin

skahlhoefer
Posts: 12
Joined: 02 Dec 2013 22:35

Re: Throw error in script

Post by skahlhoefer » 30 Aug 2014 20:40

Hi Martin,
I might try to copy the whole script into an expression condition. I've never realized the expression as a complex condition script, yet.
Nevertheless a script function would be my first choice here as I in deed want to throw an exception resp. abort immediately if the response from the previous HTTP request is empty or contains an error message.

Maybe you could think about implementing a small exit function for the next release again. ;-)

Regards,
Stefan

Post Reply