Modify Rule S1679: fix Dart example, add implementation details

This commit is contained in:
Marharyta Nedzelska 2024-08-06 17:50:08 +02:00 committed by Marharyta
parent b2a890068d
commit d836e73941

View File

@ -7,8 +7,8 @@ In such case it's recommended to use `rethrow` instead of just `throw`, to prese
----
try {
...
} catch (ex, stacktrace) {
rethrow ex; // preserves the original exception with its stacktrace
} catch (ex) {
rethrow; // preserves the original exception with its stacktrace
}
----
@ -41,11 +41,30 @@ void foo() {
methodThrowsException();
} catch (ex) {
// ...
rethrow ex;
rethrow;
}
}
----
== Resources
* https://dart.dev/tools/linter-rules/use_rethrow_when_possible[Dart Lint rule]
* Dart Docs - https://dart.dev/tools/linter-rules/use_rethrow_when_possible[Dart Linter rule - use_rethrow_when_possible]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
* Use 'rethrow' to rethrow a caught exception.
=== Highlighting
The `throw` statement with the argument.
'''
endif::env-github,rspecator-view[]