Skip to content

Commit 32de591

Browse files
committed
Add Reraising exceptions rule
1 parent b75b0f2 commit 32de591

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.adoc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,6 +1968,31 @@ fail SomeException, 'message'
19681968
raise SomeException, 'message'
19691969
----
19701970

1971+
=== Reraising exceptions [[reraising-exceptions]]
1972+
1973+
Call `raise` without an exception argument when reraising exceptions.
1974+
1975+
[source,ruby]
1976+
----
1977+
# bad
1978+
begin
1979+
something_that_might_fail
1980+
rescue SomeException => e
1981+
# handle SomeException
1982+
1983+
raise e
1984+
end
1985+
1986+
# good
1987+
begin
1988+
something_that_might_fail
1989+
rescue SomeException => e
1990+
# handle SomeException
1991+
1992+
raise
1993+
end
1994+
----
1995+
19711996
=== Raising Explicit `RuntimeError` [[no-explicit-runtimeerror]]
19721997

19731998
Don't specify `RuntimeError` explicitly in the two argument version of `raise`.

0 commit comments

Comments
 (0)