Added extra conditions to retry logic

We lose the ability to inspect the error body, if a different error occurs. Got any ideas for how we can make this better?