Error turned into an empty value
This is how the comment reads inline, under the flagged line.
Why it matters
Returning null or [] from a catch makes 'it failed' look like 'there was nothing'. The UI shows an empty list instead of an error.
What to do
Let it throw, or return an explicit error result the caller must handle.
Examples
try {
return await listOrders();
} catch {
return [];
}return await listOrders();
What it catches
It reads the shape of the code: functions, blocks, loops and calls. Languages: TypeScript and JavaScript, Python. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
try {
return go();
} catch (e) {
return [];
}
try:
return go()
except KeyError:
return None
Left alone
try {
return go();
} catch (e) {
throw e;
}
Research
Fallbacks and guards that hide missing data (`?? []`, `.get(k, "")`, `hasattr` probes, catch that returns empty, long `?.` chains). A timeout looks like an empty result, and broken assumptions travel downstream.
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"catch-returns-empty"
],
"severity": {
"catch-returns-empty": "low"
}
}
}