canneverbe / Ketarin

Ketarin - application download helper
http://ketarin.org/
Other
135 stars 19 forks source link

Need an error when regular expression fails to match successfully. #22

Closed 7th-heaven closed 11 months ago

7th-heaven commented 11 months ago

I am using version 1.8.11.0, When the page changes(still exists) which the URL pointing to. Causing the regular expression to fail to match successfully. Ketarin does not throw an error but defaults to considering it as a successful update...

shawnkhall commented 11 months ago

This behavior is expected. One can't assume that simply because a variable returns empty that it's not being parsed as the operator intends. I have dozens of apps where the specific behavior is controlled by whether one or more variables are empty.

If you want to monitor for an empty variable then there are built-in ways to do so. For your specific goal, you'll want to use the ifemptythenerror function.

I assume that you're using regexp to capture either the version or the download URL. In either case, just make sure that you're using the ifemptythenerror function on one of the subsequent variables where it would be parsed. The download field is ideal, as it is guaranteed to be processed.

For example, if you capture the download URL to a variable named sdownload then your download URL which would normally be {sdownload} would simply be replaced with {sdownload:ifemptythenerror}.

If you build the download URL using the version number in some way then you could do the same thing for your version variable:

 https://example/path/file-{version:ifemptythenerror}.ext

The way the ifemptythenerror function works, it will either return the contents of the variable (1.2.3 or example/path/file.ext) or it will raise an error saying that the variable is empty.

7th-heaven commented 11 months ago

This behavior is expected. One can't assume that simply because a variable returns empty that it's not being parsed as the operator intends. I have dozens of apps where the specific behavior is controlled by whether one or more variables are empty.

If you want to monitor for an empty variable then there are built-in ways to do so. For your specific goal, you'll want to use the ifemptythenerror function.

I assume that you're using regexp to capture either the version or the download URL. In either case, just make sure that you're using the ifemptythenerror function on one of the subsequent variables where it would be parsed. The download field is ideal, as it is guaranteed to be processed.

For example, if you capture the download URL to a variable named sdownload then your download URL which would normally be {sdownload} would simply be replaced with {sdownload:ifemptythenerror}.

If you build the download URL using the version number in some way then you could do the same thing for your version variable:

 https://example/path/file-{version:ifemptythenerror}.ext

The way the ifemptythenerror function works, it will either return the contents of the variable (1.2.3 or example/path/file.ext) or it will raise an error saying that the variable is empty.

It's worked. Thank you for the reply.