Skip to main content

avoid-throw-in-catch-block

added in: 1.0.0 warning

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
}
}