Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

correctness.control-flow

Avoid overly broad exception handlers

Catching `Exception` or `BaseException` makes error handling too broad.

#Metadata

Rule ID
py.correctness.broad-exception-handler
Severity
high
Confidence
0.95
Languages
python
Presets
recommended, strict
Stability
stable
Applies to
block
Tags
correctness, python, rules-catalog

#Why it matters

Broad handlers hide programming errors and can interfere with expected process-level exceptions.

#Remediation

Catch only the concrete exception classes this block can recover from.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/python/py.correctness.broad-exception-handler.rule.yaml.