unused_catch_clause
The exception variable '{0}' isn't used, so the 'catch' clause can be removed.
Description
#The analyzer produces this diagnostic when a catch
clause is found, and neither the exception parameter nor the optional stack trace parameter are used in the catch
block.
Example
#The following code produces this diagnostic because e
isn't referenced:
dart
void f() {
try {
int.parse(';');
} on FormatException catch (e) {
// ignored
}
}
Common fixes
#Remove the unused catch
clause:
dart
void f() {
try {
int.parse(';');
} on FormatException {
// ignored
}
}
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.