Change in vdsm[master]: vdsm: storage replace/remove too generic except handlers

nsoffer at redhat.com nsoffer at redhat.com
Fri Jan 3 00:50:44 UTC 2014


Nir Soffer has posted comments on this change.

Change subject: vdsm: storage replace/remove too generic except handlers
......................................................................


Patch Set 2:

(4 comments)

This is too big. Lets fix this module by module, correcting each case in the best way.

A start could be dispatcher.py, after addressing current comments.

....................................................
File vdsm/storage/dispatcher.py
Line 40:         self.help = None
Line 41:         try:
Line 42:             if hasattr(func.im_self, "help"):
Line 43:                 self.help = getattr(func.im_self, "help")
Line 44:         except AttributeError:
+1 for removing this stupid pointless try block as Dan suggests.
Line 45:             pass
Line 46: 
Line 47:         if not self.help:
Line 48:             try:


Line 50:             except AttributeError:
Line 51:                 pass
Line 52: 
Line 53:         if not self.help:
Line 54:             self.help = "No help available for method %s" % name
Lines 45-54 can be remove if using Dan suggested code.
Line 55: 
Line 56:     def run(self, *args, **kwargs):
Line 57:         try:
Line 58:             ctask = task.Task(id=None, name=self.name)


Line 66:             except se.GeneralException as e:
Line 67:                 self.log.error(e.response())
Line 68:                 return e.response()
Line 69:             except BaseException as e:
Line 70:                 # Do we really need to catch BaseException?
No, replace it to Exception.
Line 71:                 self.log.error(e, exc_info=True)
Line 72:                 defaultException = ctask.defaultException
Line 73:                 if defaultException and hasattr(defaultException, "response"):
Line 74:                     resp = defaultException.response()


Line 118:             if hasattr(self, method):
Line 119:                 help = getattr(self, method).im_self.help
Line 120:         except AttributeError:
Line 121:             pass
Line 122:         return help
Replace whole body with:

    try:
        return getattr(self, method).im_self.help
    except AttributeError:
        return "No help available for method %s" % method


-- 
To view, visit http://gerrit.ovirt.org/17751
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ia09dcada40bca3f16f94ad7a6c83e6d7a85ade77
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <vfeenstr at redhat.com>
Gerrit-Reviewer: Better Saggi <bettersaggi at gmail.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Eduardo <ewarszaw at redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Martin Sivák <msivak at redhat.com>
Gerrit-Reviewer: Michal Skrivanek <michal.skrivanek at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Ohad Basan <obasan at redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>
Gerrit-Reviewer: Yeela Kaplan <ykaplan at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list