Change in vdsm[master]: lib: migration: add response.is_failure helper

nsoffer at redhat.com nsoffer at redhat.com
Tue Jul 7 20:21:23 UTC 2015


Nir Soffer has posted comments on this change.

Change subject: lib: migration: add response.is_failure helper
......................................................................


Patch Set 6:

(2 comments)

https://gerrit.ovirt.org/#/c/42795/6/lib/vdsm/response.py
File lib/vdsm/response.py:

Line 26: 
Line 27: class MalformedResponse(Exception):
Line 28:     """
Line 29:     Malformed response value
Line 30:     """
This does not add much value, just repeating the class name.  I think the name clear enough.
Line 31: 
Line 32:     def __init__(self, res):
Line 33:         super(MalformedResponse, self).__init__(
Line 34:             "Malformed response: %s" % str(res))


Line 30:     """
Line 31: 
Line 32:     def __init__(self, res):
Line 33:         super(MalformedResponse, self).__init__(
Line 34:             "Malformed response: %s" % str(res))
We don't need to repeat the name of the class in the message. If you try to raise this exception, we will get:

    MalformedResponse: Malformed response: foo

Also initializing Exception for formatting the error string is little clumsy.

Better use this pattern used elsewhere in vdsm:

    class MalformedResponse(Exception):

        def __init__(self, response):
            self.response = response

        def __str__(self):
            return "Missing required key %r" % self.response
Line 35:         self.response = res
Line 36: 
Line 37: 
Line 38: def success(message=None, **kwargs):


-- 
To view, visit https://gerrit.ovirt.org/42795
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I6ccefec4f1bebcb2ca64f0bc9f6b9e9954dbf04c
Gerrit-PatchSet: 6
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Marcin Mirecki <mmirecki at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list