You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ cat /tmp/a.rb
begin
1 / 0
rescue => e
raise StandardError, 'hi', e.backtrace
end
$ ruby /tmp/a.rb
/tmp/a.rb:2:in `/': hi (StandardError)
from /tmp/a.rb:2:in `<main>'
$ cat .rubocop.yml
RaiseArgs:
EnforcedStyle: compact
No autocorrect. Or if you want to get fancy you can autocorrect to
$ cat /tmp/a.rb
begin
1 / 0
rescue => e
new_e = StandardError.new('hi')
new_e.set_backtrace(e.backtrace)
raise new_e
end
Actual behavior
$ rubocop -a a.rb
Inspecting 1 file
C
Offenses:
a.rb:4:3: C: [Corrected] Provide an exception object as an argument to raise.
raise StandardError, 'hi', e.backtrace
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 file inspected, 1 offense detected, 1 offense corrected
$ cat /tmp/a.rb
begin
1 / 0
rescue => e
raise StandardError.new('hi', e.backtrace)
end
$ ruby /tmp/a.rb
/tmp/a.rb:4:in `initialize': wrong number of arguments (given 2, expected 0..1) (ArgumentError)
from /tmp/a.rb:4:in `new'
from /tmp/a.rb:4:in `rescue in <main>'
from /tmp/a.rb:1:in `<main>'
Expected behavior
No autocorrect. Or if you want to get fancy you can autocorrect to
Actual behavior
Steps to reproduce the problem
See above
RuboCop version
The text was updated successfully, but these errors were encountered: