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 don't think this is worth adding to Try::Tiny itself (it's a bit of an edge case). It wouldn't be hard to write a wrapper module that did this though, and I think that's where this functionality would belong.
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:
Ugly!
This patch makes it possible to simply call retry:
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