From 03d788fc5b0c37d7dfd38a7d42c1e4e419e006a6 Mon Sep 17 00:00:00 2001 From: Justin Hynes Date: Fri, 19 Feb 2021 09:51:10 -0500 Subject: [PATCH] Log error when failing to award program certificate --- openedx/core/djangoapps/programs/tasks.py | 4 ++-- openedx/core/djangoapps/programs/tests/test_tasks.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openedx/core/djangoapps/programs/tasks.py b/openedx/core/djangoapps/programs/tasks.py index c80ec6d2f4..8183dc469a 100644 --- a/openedx/core/djangoapps/programs/tasks.py +++ b/openedx/core/djangoapps/programs/tasks.py @@ -255,9 +255,9 @@ def award_program_certificates(self, username): # lint-amnesty, pylint: disable f"Unable to award certificate to user {username} for program {program_uuid}. " "The program might not be configured." ) - except Exception: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # keep trying to award other certs, but retry the whole task to fix any missing entries - LOGGER.warning(f"Failed to award certificate for program {program_uuid} to user {username}.") + LOGGER.exception(f"Failed to award certificate for program {program_uuid} to user {username}.") failed_program_certificate_award_attempts.append(program_uuid) if failed_program_certificate_award_attempts: diff --git a/openedx/core/djangoapps/programs/tests/test_tasks.py b/openedx/core/djangoapps/programs/tests/test_tasks.py index e22a3efb0b..70256522e6 100644 --- a/openedx/core/djangoapps/programs/tests/test_tasks.py +++ b/openedx/core/djangoapps/programs/tests/test_tasks.py @@ -343,7 +343,7 @@ class AwardProgramCertificatesTestCase(CatalogIntegrationMixin, CredentialsApiCo mock_award_program_certificate.side_effect = self._make_side_effect([Exception('boom'), None]) with mock.patch(TASKS_MODULE + '.LOGGER.info') as mock_info, \ - mock.patch(TASKS_MODULE + '.LOGGER.warning') as mock_warning: + mock.patch(TASKS_MODULE + '.LOGGER.exception') as mock_warning: tasks.award_program_certificates.delay(self.student.username).get() assert mock_award_program_certificate.call_count == 3