Changed logging to raising an error for max retries.