ALL-ERRO0004 · raise_inside_guarded_region
Count guards that catch a failure their own protected region threw.
This is a deterministic rule for all languages. Read its implementation.
Definition
Section titled “Definition”Read every guard one declaration states, take the error names its own protected region raises,
and report the guard when one of its handler clauses would catch one of them. A clause catches
it when it names that error, when it names a base error such as Exception or Error, or when
it names no type at all the way a bare except and a JavaScript catch (error) do. A raise
written there is a jump to a handler a few lines below, which is a goto wearing the clothes of
error handling, and the reader has to hold the whole region in mind to work out where control
lands.
The handler pays for it twice. It now answers both the failures the protected calls throw and the ones the body threw at itself, so it cannot recover from one without pretending to recover from the other, and a real failure from a real call arrives looking exactly like the check the body performed on purpose. Moving the check into the function that owns it leaves the guard protecting only calls it does not control, which is the one thing a guard is good at.
Continue with evidence and references, or open the examples.