Decorator to retry calling a function upon error