Will It Vibe logoWill It Vibe?
PY-003Medium severity-8 points

Exception re-raised without preserving cause

Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 8 points from that category, once per scan, no matter how many places it turns up.

What it detects

Wrapping a caught exception in a new one without raise ... from e discards the original traceback and __cause__.

Why it matters

Wrapping a caught exception in a new one without raise ... from e (or from None) breaks Python's exception chain, so the traceback and __cause__ that would normally point back to the original error are lost. Whoever debugs the failure later sees only the new, often vaguer exception and has no way to tell what actually went wrong underneath. This is easy to introduce when converting a low-level exception into a higher-level, more readable one, but the conversion should preserve the chain, not discard it.

How to fix it

Add from exc (using the caught exception variable name) to the raise statement, for example raise ValueError(f"invalid amount: {raw}") from exc, so Python links the two exceptions and both show up in the traceback. If the original exception truly must be hidden (for example to avoid leaking internal details across a security boundary), use from None explicitly so the suppression is visible in the code rather than accidental.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Code Quality & Syntax checks