diff options
| author | Lucian Copeland <hierophect@gmail.com> | 2021-02-17 11:39:46 -0500 |
|---|---|---|
| committer | Lucian Copeland <hierophect@gmail.com> | 2021-02-17 11:39:46 -0500 |
| commit | a3aa48b8dffe5ed3c921ff3e9de5423ff1c588b1 (patch) | |
| tree | c8978ddb2314944dbb6876de5ebdf90e3dd0071d /docs | |
| parent | 2d2c40b3d44bc7b73abb9534a7eeab3c27049b26 (diff) | |
| parent | 261b077209bc668de843015e4f5c26e474214769 (diff) | |
Merge remote-tracking branch 'upstream/main' into manual-tests
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/design_guide.rst | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/design_guide.rst b/docs/design_guide.rst index 7a8c76b50..331757034 100644 --- a/docs/design_guide.rst +++ b/docs/design_guide.rst @@ -165,6 +165,24 @@ use what. Here is more info on properties from `Python <https://docs.python.org/3/library/functions.html#property>`_. +Exceptions and asserts +-------------------------------------------------------------------------------- + +Raise an appropriate `Exception <https://docs.python.org/3/library/exceptions.html#bltin-exceptions>`_, +along with a useful message, whenever a critical test or other condition fails. + +Example:: + + if not 0 <= pin <= 7: + raise ValueError("Pin number must be 0-7.") + +If memory is constrained and a more compact method is needed, use `assert` +instead. + +Example:: + + assert 0 <= pin <= 7, "Pin number must be 0-7." + Design for compatibility with CPython -------------------------------------------------------------------------------- |
