Here are some things you might consider depending upon what it is you really want to achieve.
- Make the results different for the user (then the problem goes away). Why not tell the user that the reason for the error is that foo is more than 10 - isn't this useful information to them?
- If you want to continue to hide the specific error from the user for some reason then simply add in a differing response for your own use which the user won't see. This might be:
- Throw different exceptions
- Raise different warnings
- Return different values from the subroutine
- Use Devel::Cover to ensure that your test suite is exercising all the possibilities. You do have a test suite, don't you?