Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Exception type too broad in error handling #8093

Copy link
Copy link

Description

@goransh-buh
Issue body actions

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.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.