From 32de5914b0b4494e911316069b63cb5467ee557e Mon Sep 17 00:00:00 2001 From: Lovro Bikic Date: Sun, 10 Aug 2025 10:58:14 +0200 Subject: [PATCH] Add Reraising exceptions rule --- README.adoc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.adoc b/README.adoc index 7b006ce4..b6f1d28c 100644 --- a/README.adoc +++ b/README.adoc @@ -1968,6 +1968,31 @@ fail SomeException, 'message' raise SomeException, 'message' ---- +=== Reraising exceptions [[reraising-exceptions]] + +Call `raise` without an exception argument when reraising exceptions. + +[source,ruby] +---- +# bad +begin + something_that_might_fail +rescue SomeException => e + # handle SomeException + + raise e +end + +# good +begin + something_that_might_fail +rescue SomeException => e + # handle SomeException + + raise +end +---- + === Raising Explicit `RuntimeError` [[no-explicit-runtimeerror]] Don't specify `RuntimeError` explicitly in the two argument version of `raise`.