Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adding exception handling #184

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,21 @@ def process_transaction(self, subsidy, txn):
"""
logger.info(f"Processing {subsidy.uuid} transaction {txn.uuid}")

if txn.lms_user_email is None and txn.lms_user_id is not None:
lms_user_email = subsidy.email_for_learner(txn.lms_user_id)
txn.lms_user_email = lms_user_email
logger.info(f"Found {lms_user_email} for {subsidy.uuid} transaction {txn.uuid}")
if txn.content_title is None and txn.content_key is not None:
content_title = subsidy.title_for_content(txn.content_key)
txn.content_title = content_title
logger.info(f"Found {content_title} for {subsidy.uuid} transaction {txn.uuid}")
try:
if txn.lms_user_email is None and txn.lms_user_id is not None:
lms_user_email = subsidy.email_for_learner(txn.lms_user_id)
txn.lms_user_email = lms_user_email
logger.info(f"Found {lms_user_email} for {subsidy.uuid} transaction {txn.uuid}")
except Exception as e: # pylint: disable=broad-exception-caught
logger.exception(f"Error while processing lms_user_email for {subsidy.uuid} transaction {txn.uuid}: {e}")

try:
if txn.content_title is None and txn.content_key is not None:
content_title = subsidy.title_for_content(txn.content_key)
txn.content_title = content_title
logger.info(f"Found {content_title} for {subsidy.uuid} transaction {txn.uuid}")
except Exception as e: # pylint: disable=broad-exception-caught
logger.exception(f"Error while processing content_title for {subsidy.uuid} transaction {txn.uuid}: {e}")

if not self.dry_run:
txn.save()
Expand Down
Loading