Using catch in {error} function

I see in the documentation for {error} it uses {if: catch(count <= 0, yes)}. How is this different from {if: count <=0}

Hi @tonyd.

Without using the catch function, non-numeric inputs will make the comparison condition fail, raising an error like this:

Count: {formtext: name=count; default=a} (count must be greater than 0)

{if: count <= 0}{error: The count is not greater than 0!; block=yes}{endif}

As you can see, your explicit error message didn't show in the previous example because the comparison itself has failed. However, when using the catch function, even non-numeric inputs will not make the condition fail, and your explicit error message will show instead like this:

Count: {formtext: name=count; default=a} (count must be greater than 0)

{if: catch(count <= 0, yes)}{error: The count is not greater than 0!; block=yes}{endif}

I hope the difference is clear now.

Thanks for the clarification.

1 Like