From Dan Kenigsberg <[email protected]>:

Dan Kenigsberg has submitted this change and it was merged.

Change subject: exception: Add ContextException
......................................................................


exception: Add ContextException

VdsmExcpetion subclasses generate unhelpful error messages with no
context about the error, making debugging harder on both vdsm and its
clients.

GeneralException attempts to improve this by adding *value argument, and
rendering the value with the message, but this create unclear error
messages:

    Storage pool not connected: ("d607ab66-6733-4ab4-9dcd-32e7fe61fa87",)

Some exceptions are overriding __init__ to add specific arguments and
formatting; this creates better messages, but it does not scale.

This patch adds a new ContextException with a reason and **kwargs
arguments.  The arguments are stored into a context dict, and formatted
with the static message.

Example usage:

    raise HotplugLeaseFailed(reason="Not hot enough", temperature=42)

Would render this message:

    Failed to hotplug lease: {"reason": "Not hot enough", "temperature": 42}

The real error should include more useful information, like the lease
details and the error message from libvirt.

When all exceptions are converted to use ContextException, we can merge
it back into VdsmException.

Change-Id: Id9b2bd8630ce5713123aa84042ea2110fd1dea1d
https://bugzilla.redhat.com/1408825
Signed-off-by: Nir Soffer <[email protected]>
---
M lib/vdsm/common/exception.py
M tests/exception_test.py
2 files changed, 70 insertions(+), 2 deletions(-)

Approvals:
  Piotr Kliczewski: Looks good to me, but someone else must approve
  Nir Soffer: Verified
  Jenkins CI: Passed CI tests
  Dan Kenigsberg: Looks good to me, approved
  Francesco Romani: Looks good to me, but someone else must approve
  Martin Polednik: Looks good to me, but someone else must approve



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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id9b2bd8630ce5713123aa84042ea2110fd1dea1d
Gerrit-PatchSet: 11
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <[email protected]>
Gerrit-Reviewer: Adam Litke <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: Francesco Romani <[email protected]>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Martin Polednik <[email protected]>
Gerrit-Reviewer: Nir Soffer <[email protected]>
Gerrit-Reviewer: Piotr Kliczewski <[email protected]>
Gerrit-Reviewer: Tal Nisan <[email protected]>
Gerrit-Reviewer: gerrit-hooks <[email protected]>
_______________________________________________
vdsm-patches mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to