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

Refactor get repo methods to conditionally raise MissingRecordError #158

Open
VKTB opened this issue Jan 23, 2024 · 0 comments
Open

Refactor get repo methods to conditionally raise MissingRecordError #158

VKTB opened this issue Jan 23, 2024 · 0 comments

Comments

@VKTB
Copy link
Collaborator

VKTB commented Jan 23, 2024

We do quite a lot of the below around the codebase:

system = self._system_repository.get(item.system_id)
if not system:
    raise MissingRecordError(f"No system found with ID: {item.system_id}")

It might be better if we modify the definition of the get repo methods to have a parameter like raise_if_none=False and change their logic to raise MissingRecordError if True is passed for raise_if_none. This way, we can just call self._system_repository.get(item.system_id, raise_if_none=True), meaning that we will not have to repeat the same logic in a few places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

1 participant