Exception handling needs to be fixed

Bug #1542804 reported by Eva Balycheva
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python client library for Zaqar
Fix Released
Medium
Eva Balycheva

Bug Description

I noticed some problems:

1. In some cases no information is provided for the CLI user these exceptions is raised: https://github.com/openstack/python-zaqarclient/blob/master/zaqarclient/transport/http.py#L30. For example, try "openstack pool show unexisting_pool". It is because the server returns no message in the 404 response body. And the user sees the empty string.

2. When the CLI user experiences the error not from python-zaqarclient code, but, for example, from keystoneclient when credentials are bad, only the exception's message is shown. The name of the exception remains hidden, though it can give additional hint to the user.

3. Only in few kinds of error situations the CLI user gets zaqar-related error. Example is "openstack queue get metadata --os-queues-api-version=1", where the error will be shown if the queue does not exist.

4. Some of the error messages will never be shown to the CLI user, but are intended to be shown. Examples:
Pool creation: https://github.com/openstack/python-zaqarclient/blob/master/zaqarclient/queues/v1/cli.py#L261
Subscription creation: https://github.com/openstack/python-zaqarclient/blob/master/zaqarclient/queues/v2/cli.py#L160

5. The information about what exceptions can be raised by "Client" class's methods is missing in method docstrings.

Possible solution:

1. Catch each exception in the CLI code to provide the CLI user this information wrapped in nice message: exception's name and exception's message. This can be done by some new decorator.

2. Make all exceptions in zaqarclient/transport/errors.py show at least error response code, so when Zaqar returns response code without description, there will be some message for the CLI user instead of blank line. Let's also add title to the exception message instead of showing just description (most of error responses from Zaqar are in title-description format). In case the response from Zaqar is not in title-description format, include response body text to the exception message.

3. Update docstrings of the Client class's methods to list possible exceptions that can be raised. (Maybe)

4. Fix error messages that never show themselves.

Eva Balycheva (ubershy)
Changed in python-zaqarclient:
assignee: nobody → Eva Balycheva (ubershy)
Eva Balycheva (ubershy)
description: updated
Eva Balycheva (ubershy)
description: updated
Eva Balycheva (ubershy)
description: updated
summary: - Exception handling needs to be improved
+ Exception handling needs to be fixed
Feilong Wang (flwang)
Changed in python-zaqarclient:
status: New → Confirmed
importance: Undecided → Medium
Eva Balycheva (ubershy)
description: updated
Eva Balycheva (ubershy)
description: updated
Eva Balycheva (ubershy)
description: updated
Eva Balycheva (ubershy)
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-zaqarclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/282114

Changed in python-zaqarclient:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-zaqarclient (master)

Reviewed: https://review.openstack.org/282114
Committed: https://git.openstack.org/cgit/openstack/python-zaqarclient/commit/?id=87f0fb56b3977cc08693902a660420bdafcb5114
Submitter: Jenkins
Branch: master

commit 87f0fb56b3977cc08693902a660420bdafcb5114
Author: Eva Balycheva <email address hidden>
Date: Tue Feb 16 23:51:10 2016 +0300

    Make TransportErrors more descriptive

    Problems:

    1. In some cases no information is provided for the CLI user when
    these exceptions are raised:
    https://github.com/openstack/python-zaqarclient/blob/master/zaqarclient/
    transport/http.py#L30.
    For example, try "openstack pool show unexisting_pool". You will see
    just blank line. It is because the server returns no message in the 404
    response body. And the user sees the blank line.

    2. Most of the error responses from Zaqar have bodies in
    title-description format. TransportErrors can only show descriptions
    from these responses. It's better to include also titles in the
    client's exception messages.

    3. Some of the error responses from Zaqar are not in title-description
    format, but still have some info in their bodies. It's better to include
    this info to the client's exception message.

    Solution:

    This patch makes all exceptions in zaqarclient/transport/errors.py show
    at least error response code. The patch TransportErrors properly gather
    the info from Zaqar's error response bodies and show it.

    Partial-Bug: 1542804

    Change-Id: Ie2cc3081a5dd7c4f21c29bdf78a9bad76b515121

wangxiyuan (wangxiyuan)
Changed in python-zaqarclient:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.