Cater for errors being nil and update checks for retryable errors
For errors.HTTPWithError, if err is nil then the program panics.This needs to be handled more gracefully.
Also add some further checks for errors.IsRetryableError.
Edited by Subhan Shah