Improved retry method allowing exception class tuning