diff --git a/jobs/payment-jobs/tasks/stale_payment_task.py b/jobs/payment-jobs/tasks/stale_payment_task.py index f91f1836a..e3480821c 100644 --- a/jobs/payment-jobs/tasks/stale_payment_task.py +++ b/jobs/payment-jobs/tasks/stale_payment_task.py @@ -115,7 +115,8 @@ def _verify_created_direct_pay_invoices(cls): TransactionService.update_transaction(transaction.id, pay_response_url=None) except HTTPError as http_err: - if http_err.response is not None and http_err.response.status_code == 404: - current_app.logger.info(f'Invoice not found (404). Skipping invoice id: {invoice.id}') - continue - current_app.logger.error(f'Error verifying invoice {invoice.id}: {http_err}', exc_info=True) + if http_err.response is None or http_err.response.status_code != 404: + current_app.logger.error(f'HTTPError on verifying invoice {invoice.id}: {http_err}', exc_info=True) + current_app.logger.info(f'Invoice not found (404) at PAYBC. Skipping invoice id: {invoice.id}') + except Exception as err: # NOQA # pylint: disable=broad-except + current_app.logger.error(f'Error verifying invoice {invoice.id}: {err}', exc_info=True)