Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Commit

Permalink
Chain exceptions together for context
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelhwilliams committed Nov 29, 2024
1 parent 60d6c91 commit c4501d4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions db/queries/tags/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ def update_tags(tags, fund_id, round_id):
tag.type_id = tag_type_id if tag_type_id is not None else tag.type_id
tag.active = active_status if active_status is not None else tag.active

except NoResultFound:
except NoResultFound as e:
# If the tag doesn't exist, raise an error
raise ValueError(
f"Tag with id '{tag_id}' does not exist for fund_id '{fund_id}' and round_id '{round_id}'."
)
) from e

updated_tags.append(tag)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_db_allocation_associations.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ def test_create_user_application_association(_db, seed_application_records):
assert {"assigner": assigner_id, "status": "activated"} == list(new_association.log.values())[0]
try:
datetime.fromisoformat(list(new_association.log.keys())[0])
except ValueError:
raise AssertionError("log keys should be in isoformat")
except ValueError as e:
raise AssertionError("log keys should be in isoformat") from e


@pytest.mark.apps_to_insert([{**test_input_data[0]}])
Expand Down
4 changes: 2 additions & 2 deletions tests/test_db_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def test_non_blob_columns_mutable(_db, seed_application_records):
picked_row = get_assessment_record(seed_application_records[0]["application_id"])
picked_row.workflow_status = "IN_PROGRESS"
_db.session.commit()
except sqlalchemy.exc.InternalError:
raise AssertionError
except sqlalchemy.exc.InternalError as e:
raise AssertionError from e
finally:
_db.session.rollback()

Expand Down

0 comments on commit c4501d4

Please sign in to comment.