doy/try-tiny — pull request #1 by cobber (2012-01-14 14:33:25+00:00)
Title: add retry() function?

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