Skip to content

Exception type too broad in error handling #68790

@goransh-buh

Description

@goransh-buh

Bug Report

Description

Some except clauses catch overly broad exception types (e.g., bare except: or except Exception:), which can accidentally swallow important errors like KeyboardInterrupt or SystemExit.

Example

# Problematic:
try:
    do_something()
except:  # catches EVERYTHING including KeyboardInterrupt
    pass

# Better:
try:
    do_something()
except ValueError as e:
    logger.warning(f"Value error: {e}")

Expected Behavior

Exception handlers should catch only the specific exceptions they know how to handle.

Impact

  • Makes it impossible to interrupt the program with Ctrl+C in some cases
  • Hides unexpected errors that should be investigated
  • Makes debugging significantly harder

Suggested Fix

Replace broad except clauses with specific exception types wherever possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions