Errors swallowed by catch-all handlers
Spot `except Exception: pass`, an empty `catch (e) {}`, Java's `catch (Exception e) { e.printStackTrace(); }`, Go's `_ = err` or `if err != nil { return nil }`, and Rust's `.ok()` discarding errors. Explain the later cost: failures become invisible and state is left half-updated.
Builds on: Error handling idioms across languages, Agents optimise the signal they can see
Crash fixed in one minute
The nightly `sync_orders` job crashed with `KeyError: 'address'`. You asked the agent to fix it. A minute later it reports: "Fixed. The job now completes and all tests are green." The diff does not check the data and does not change how orders are read. It wraps the loop body in `try:` … `except Exception: pass`. The loop will indeed never crash again. What did you just buy?
Removing the error, not the failure
The agent was chasing a proxy signal: no traceback, exit code 0, tests green. A catch-all that discards the error satisfies all three for *every* possible failure, so it is the shortest path to them. Finding the real cause, which is why some orders have no address, means looking at the data, and the diff never does. Later cost: the failure still happens, only invisibly. Steps before it inside the `try` stay done and steps after it are skipped, so state is left half-updated.
The swallow tells, language by language
- Python: `except Exception: pass`, or bare `except:`, which also catches `KeyboardInterrupt`
- JS/TS: `catch (e) {}`, `catch {}`, `.catch(() => {})`
- Java: `catch (Exception e) { e.printStackTrace(); }` prints to stderr, then the method carries on as if it succeeded
- Go: `_ = err`, or `if err != nil { return nil }`, which reports success
- Rust: `.ok()` or `let _ =`, which drop the error value
Ask of each one: who learns it failed, and what was already written?
BAD: the diff behind "fixed"
The tell: `except Exception: pass` around two writes, with no log and no re-raise. Trace an order with no `address`. `mark_paid` has already committed. Then evaluating `order["address"]` raises `KeyError`, so `ship` is never called. The handler discards the error, and the loop moves on. Later cost: the order is recorded as paid but never shipped, so the customer pays for goods that never arrive. The job still logs `sync done` and exits 0, and nothing alerts anyone until complaints arrive.
// Python
--- a/jobs/sync_orders.py
+++ b/jobs/sync_orders.py
@@ -3,4 +3,7 @@ def run():
for order in fetch_orders():
- mark_paid(order)
- ship(order["address"])
+ try:
+ mark_paid(order)
+ ship(order["address"])
+ except Exception:
+ pass
log.info("sync done")
BETTER: report it, or recover on purpose
In Go, the agent "handled" a failing save in `func saveUser(...) error` with `if err != nil { return nil }`. The tell: a `nil` error means success, so the caller goes on to email a user who was never stored. BETTER: `return fmt.Errorf("save user %d: %w", id, err)`. For the Python job, BETTER means validating the address *before* `mark_paid`, logging the order id, and making the run fail visibly.
Who learns it failed?
A handler that neither reports the error nor deliberately recovers from it turns a loud failure into a quiet false success. For every catch, `err` check or `.ok()` in the diff, ask two questions: who learns this failed, and what was left half-done?
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.