#276 new
Jarl Friis

rescue clauses does not catch exceptions

Reported by Jarl Friis | January 13th, 2010 @ 12:38 AM

Many places in the code there are statements like this
rescue => e

A type must be specified so such clauses should at least be
rescue Exception => e

However I will recommend to be more specific on such rescue clauses

I ran into this problem when I was going from running cruisecontrolrb manually to running cruisecontrolrb in daemon mode.

I attach a patch for that specific problem. But the problem is bigger than that, see for example the output of
grep -r 'rescue =>' *

Jarl

Comments and changes to this ticket

  • Tony Spataro

    Tony Spataro March 1st, 2010 @ 08:56 AM

    Hi Jarl,

    I wouldn't apologize for your newbie0ness just yet. In fact, it's rather dangerous only to catch StandardError, because StandardError is a subclass of Exception and most application-defined exceptions do NOT inherit from StandardError, but rather from Exception.

    If one throws a string or other object, I believe Ruby automatically constructs an Exception from it, which is not caught by a "rescue => e" clause.

    "rescue => e" is a very common error in Ruby code, which has let to many mysterious non-caught exceptions in projects I've worked on. I advise everyone I work with to avoid it.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Attachments

Pages