Swallowed errors: except: pass, an empty catch, catch (Exception e) { return null; }, Go's if err != nil { return nil }
Errors and checks hidden: one of the ways AI coding agents bloat software, from lessloc's pattern catalog. lessloc catches it as swallowed-error.
What makes swallowed errors a bad practice?
The standards that call it a bad practice: CWE-390 Detection of Error Condition Without Action; CWE-1069 Empty Exception Block; CWE-396.
What does lessloc do about swallowed errors?
lessloc catches it as swallowed-error.
swallowed-error(tier 1): An error caught and dropped, such asexcept Exception: passor an empty catch. The agent hears about it right after the write.
Examples
Caught as swallowed-error:
js
export function read(f) {
try {
return f();
} catch (e) {
// ignore
}
}Written well:
js
export function read(f) {
try {
return f();
} catch (e) {
if (e.code !== "ENOENT") throw e;
}
}Caught as swallowed-error:
go
package ad
func Load(get func() error) error {
if err := get(); err != nil {
return nil
}
return nil
}
func Save(put func() error) error {
err := put()
if err != nil {
return nil
}
return nil
}Written well:
go
package ad
func Save(put func() error) error {
err := put()
if err != nil {
return err
}
return nil
}Related patterns
The other patterns in Errors and checks hidden:
- Silenced checks: lessloc catches it as
suppression. - Checks, fallbacks and catches for cases that cannot happen:
defensivecatches a null check of a value just created, a type re-checked inside private code and?.on a fresh object. - Removing validation or error handling to shrink code: lessloc catches it as
removed-safeguard.

