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

[WIP] Add comments/docstrings to exceptions #1873

Draft
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

craddm
Copy link
Contributor

@craddm craddm commented May 9, 2024

✅ Checklist

  • You have given your pull request a meaningful title (e.g. Enable foobar integration rather than 515 foobar).
  • You are targeting the appropriate branch. If you're not certain which one this is, it should be develop.
  • Your branch is up-to-date with the target branch (it probably was when you started, but it may have changed since then).
  • You have marked this pull request as a draft and added '[WIP]' to the title if needed (if you're not yet ready to merge).

⤴️ Summary

Adds descriptive comments and/or docstrings to exceptions.

Also checks consistency of usage across the codebase.

🌂 Related issues

Closes #1518

🔬 Tests

@craddm craddm requested a review from a team as a code owner May 9, 2024 15:30
@craddm craddm marked this pull request as draft May 9, 2024 15:30
Copy link

github-actions bot commented May 10, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  data_safe_haven/commands
  shm.py 108
  sre.py 179
  data_safe_haven/exceptions
  __init__.py
Project Total  

This report was generated by python-coverage-comment-action

@craddm
Copy link
Contributor Author

craddm commented May 10, 2024

Currently the custom exceptions use the following hierarchy:
image

@craddm
Copy link
Contributor Author

craddm commented May 16, 2024

I'm still trying to understand what we want the errors to achieve. At the moment they're a bit of a mishmash.

For example, DataSafeHavenParameterError is used when a user supplies a key for a context that either does not exist or already exists (when trying to create), but also when a yaml config file cannot be validated.

On the other hand, we have DataSafeHavenConfigError, which is used when no context file exists, or when a user supplies an SRE name that does not exist in the config, but also when no context is selected, or when the config file is not correct yaml.

Then we have DataSafeHavenInputError which is used when a subscription cannot be found, when there are missing values for users, when a secret already exists in a key-vault...

Finding it difficult to nail a description for some of these error classes as it's not always clear what they are intended to capture

@jemrobinson
Copy link
Member

It's totally fine for you to redesign the error names and/or inheritance structure to make more sense. I think we want things to adhere to the following guidelines:

  • everything should inherit from DataSafeHavenError eventually
  • if X and Y both inherit from A it should be because they're conceptually both a type of A but that it's worth distinguishing between them (e.g. it might be nice to distinguish Azure errors from Graph errors even though they're both some kind of Microsoft/Cloud error).
  • we (ideally) should be using each type of error in more than one place and, if possible, more than one file

Anything else you'd add to this @JimMadge ?

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

Successfully merging this pull request may close these issues.

Add descriptions/guidance for custom exceptions
3 participants