Catch block silently swallows the exception
ID |
dart.correctness.empty_catch_block |
Severity |
low |
Remediation Complexity |
medium |
Remediation Risk |
low |
Remediation Effort |
medium |
Resource |
Error Handling |
Language |
Dart |
Description
This catch has an empty body, so the failure is discarded with no trace. Handle the error, rethrow it, or at minimum log it. If the exception really is expected and ignorable, say so in a comment inside the block.
Rationale
This catch has an empty body, so the failure is discarded with no trace. Handle the error, rethrow it, or at minimum log it. If the exception really is expected and ignorable, say so in a comment inside the block.
The following code illustrates the pattern detected by this rule:
class Catches {
void swallows() {
// FLAGGED: Catch block silently swallows the exception
try {
risky();
} catch (e) {}
}
void risky() {}
}