As per the pdf document you referred above, when the status code is 500, the only error code for which we should *not* retry is 1020. For all others (including 1040), we should retry.