Skip to main content

avoid-throw-in-catch-block

added in: 1.6.0
preset: recommended

Call throw in a catch block loses the original stack trace and the original exception.

Since 2.16 version you can use Error.throwWithStackTrace.

Example

void repository() {
try {
networkDataProvider();
} on Object {
throw RepositoryException(); // LINT
}
}