Narrow bare rescue in Elixir so real errors like KeyError and typos propagate instead of being swallowed. Use to audit rescues and refactor error handling.
---
name: narrow-bare-rescue
description: "Narrow bare rescue in Elixir so real errors like KeyError and typos propagate instead of being swallowed. Use to audit rescues and refactor error handling."
effort: medium
user-invocable: true
argument-hint: "[file_path | directory | --all]"
paths:
- "**/*.ex"
- "**/*.exs"
---
# Narrow Bare Rescue
Turn `rescue _ -> fallback` into `rescue _ in [ExceptionType1, ExceptionType2] -> fallback`
so programmer bugs propagate while known failure modes stay handled.
## Why this matters
Bare rescues (`rescue _ ->`, `rescue e ->` — any form without an `in` clause) swallow
**every** exception, including `UndefinedFunctionError` from typos, `KeyError` from
misspelled map keys, and `CompileError` from bad HEEx templates. The symptom isn't a stack
trace — it's a silent `{:error, :generic}` or a `nil` fallback. Bugs that should surface
in tests or error reporters become quiet degradations.
The Erlang [Secure Coding Guide](https://www.erlang.org/doc/system/secure_coding.html) makes… install to load the full skill