doy/try-tiny — pull request #2 by cobber (2012-01-14 15:03:45+00:00)
Title: Request to add retry() feature to Try::Tiny

Hi Jesse,

I'd like to add a "retry" function to Try::Tiny.

My inspiration came while reworking the error handling in one of my projects.
I kept ending up with the following pattern:

RETRY:
try {
...
} catch {
# check what might have caused the error
# try to fix what broke
goto RETRY if $try_again;
};

Ugly!

This patch makes it possible to simply call retry:

try {
...
} catch {
# check what might have caused the error
# try to fix what broke
retry if $try_again;
};

It works much like skip() in Test::More - but doesn't require the user to set up a label and it uses perl's redo function to unwind the stack properly.

I hope you like it!

Steve