[openstack-dev] [ceilometer] overuse of 'except Exception'
Chris Dent
chdent at redhat.com
Wed Jul 23 11:13:06 UTC 2014
I was having a bit of a browse through the ceilometer code and
noticed there are a fair few instances (sixty-some) of
`except Exception` scattered about.
While not as evil as a bare except, my Python elders always pointed
out that doing `except Exception` is a bit like using a sledgehammer
where something more akin to a gavel is what's wanted. The error
condition is obliterated but there's no judgement on what happened
and no apparent effort by the developer to effectively handle
discrete cases.
A common idiom appears as:
except Exception:
LOG.exception(_('something failed'))
return
# or continue
There's no information here about what failed or why.
That's bad enough, but much worse, this will catch all sorts of
exceptions, even ones that are completely unexpected and ought to
cause a more drastic (and thus immediately informative) failure
than 'something failed'.
So, my question: Is this something we who dig around in the ceilometer
code ought to care about and make an effort to clean up? If so, I'm
happy to get started.
Thanks.
--
Chris Dent tw:@anticdent freenode:cdent
https://tank.peermore.com/tanks/cdent
More information about the OpenStack-dev
mailing list