ALL-ERRO0004 · evidence
This page continues ALL-ERRO0004 directly from its source docstring. Read its implementation.
Evidence
Section titled “Evidence”Each finding names the declaration and the guard whose own body raises. The value is the number of guards that catch what they threw.
Exceptions
Section titled “Exceptions”A raise no clause would catch leaves the guard entirely and is left alone, which is why the
names are compared at all rather than any raise in the region being reported. Comparing them
lexically is what a reader does too, and a clause that catches a subclass by a name the raise
never states is missed rather than guessed at. A guard that states no handler is how a language
spells cleanup that always runs, and since it catches nothing it is never judged. A raise
inside a callable the region declares is the very shape this rule asks for, so it is not
counted even though it is written inside the region. A guard nested inside another is judged on
its own, and both are reported when both could catch what the inner body threw. Only a callable
is judged, because a type reaches every guard it owns through the callable holding it and would
otherwise report the same one twice. handlers names the words a language opens a handler
clause with and catch_all names the base errors a clause catches everything through, so a
project whose own root error is caught that widely adds it.
References
Section titled “References”- Generalizes Ruff TRY301 raise-within-try. Open reference
- Cites “tryceratops documentation”, the linter this check came from. Open reference
- Cites “Clean Code”, chapter 7, error handling
- Cites “Refactoring”, extract function