Use the succeed statement to induce an immediate successful return from the current exec. If the function or operator has been invoked as a statement then the resulting truth value of that statement is "true".
Use the fail statement to terminate execution of the current exec unsuccessfully. If the function or operator has been invoked as a statement then the resulting truth value of that statement is "false".
Every Lava statement yields a truth value true or false. The condition part of a Lava if statement or an ifx expression is a quite normal Lava statement whose truth value is tested by the if / ifx. This truth value may be set explicitly by using succeed or fail. A function call may terminate immediately and yield the truth value false also implicitly if a failing function call statement or a failing relational statement (like 1 < 0) is executed within the function body.
Note: If you are in a function with mandatory output parameters then succeed and fail are admissible only at places in the function body where values have already been assigned to all mandatory output parameters. (This is checked and enforced by LavaPE already at programming time!)
Use the throw statement to throw an exception and to induce an immediate negative/unsuccessful return from the current exec. If the function or operator has been invoked as a statement then the resulting truth value of that statement is false.
The fail and throw statements are both inserted by clicking the fail button on the keyword toolbar. throw has an exception parameter, i.e., an expression whose value will be thrown as an exception object if present. if you delete this exception parameter then throw will be replaced by fail.
Note: You can leave a function body only if values have been assigned to all mandatory output parameters, or by throwing an exception. (This is checked and enforced by LavaPE! In this way inadvertent use of undefined outputs by the caller is prevented in Lava.)
See also: