<attempt> repeat a block until it is successful

name
attempt
xml namespace
http://moyaproject.com

Repeat a block of code if an exception is thrown. This is useful in situations where you are creating a database object with a random token, and you want to repeat the code if the random token happens to exist. The wait attribute can set a timespan to wait between attempts, which may be appropriate for connecting to servers, for example.

If an exception occurs, after times attempts, then it will be thrown normally.

Example

<attempt times="10" catch="db.*">
    <db:create model="#ValidateEmail" let:user="user" dst="validate_email" />
</attempt>
attributes
name purpose type required? default choices
catch Type of exception to catch comma list No *
times Maximum number of times to repeat attempt block integer Yes
wait Time to wait between syncs (default doesn't wait) timespan No
inherited attributes
name purpose type required? default choices
if Conditional expression expression No yes