Dart Analyze logoDart Analyze/
DRT-W1534

Non-type in catch clauseDRT-W1534

Major severityMajor
Bug Risk categoryBug Risk

The analyzer produces this diagnostic when the identifier following the on in a catch clause is defined to be something other than a type.

Example

The following code produces this diagnostic because f is a function, not a type:

void f() {
  try {
    // ...
  } on f {
    // ...
  }
}

Common fixes

Change the name to the type of object that should be caught:

void f() {
  try {
    // ...
  } on FormatException {
    // ...
  }
}