Perform the retry functionality for a promise