ruby-style-guide icon indicating copy to clipboard operation
ruby-style-guide copied to clipboard

Use StandardError over Exception

Open denys281 opened this issue 5 years ago • 3 comments

Based on discussion: https://github.com/rubocop-hq/rubocop/pull/7325/files#r320964544

Rubocop issue: https://github.com/rubocop-hq/rubocop/issues/7299

denys281 avatar Sep 16 '19 14:09 denys281

@marcandre Could you take a look? Cop w merged some time ago.

denys281 avatar Aug 11 '20 20:08 denys281

This PR still needs work... It's true one should not raise an Exception, but it is not true one should raise a StandardException; it's more an abstract base class than anything else. One should raise the appropriate exception (e.g. TypeError) or if nothing fits, a RuntimeError (which shouldn't be specified). Maybe it would be best to modify the "don't rescue Exception" section, as they are related... Don't raise one because you should not rescue those...

marcandre avatar Aug 11 '20 21:08 marcandre

Ping @denys281

pirj avatar Jan 10 '23 21:01 pirj