diff options
author | Louis Taylor <kragniz@gmail.com> | 2014-09-15 20:04:38 +0000 |
---|---|---|
committer | Louis Taylor <kragniz@gmail.com> | 2014-09-15 20:04:38 +0000 |
commit | 4d6b94a6794c0cc6ae35e550d23323820881eec7 (patch) | |
tree | 796baa5ab067ef6767ce0d1050b6fe956401e486 | |
parent | 4a5903bce7cbe7e8384541b66020074b7fbe1702 (diff) | |
download | python-glanceclient-4d6b94a6794c0cc6ae35e550d23323820881eec7.tar.gz |
Print traceback to stderr if --debug is set
This change allows easier debugging of client related issues, with a
full traceback printed out when an uncaught error occurs in the client.
Previously, it could be hard to find the portion of code raising an
exception, with just the message from the exception being displayed.
Previous behaviour (with a rather artificial client error being raised):
$ glance --debug image-list
Contrived exception
Behaviour after this patch:
$ glance --debug image-list
Traceback (most recent call last):
File "/opt/stack/python-glanceclient/glanceclient/shell.py", line 590, in main
args.func(client, args)
File "/opt/stack/python-glanceclient/glanceclient/v1/shell.py", line 77, in do_image_list
raise(Exception('Contrived exception'))
Exception: Contrived exception
Contrived exception
Change-Id: Id7b76b707e5fc16a0402dcb104ec40787e0ffbe2
-rw-r--r-- | glanceclient/shell.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/glanceclient/shell.py b/glanceclient/shell.py index 2640ef5..92de22e 100644 --- a/glanceclient/shell.py +++ b/glanceclient/shell.py @@ -26,6 +26,7 @@ import logging import os from os.path import expanduser import sys +import traceback import six.moves.urllib.parse as urlparse @@ -589,6 +590,12 @@ class OpenStackImagesShell(object): args.func(client, args) except exc.Unauthorized: raise exc.CommandError("Invalid OpenStack Identity credentials.") + except Exception: + #NOTE(kragniz) Print any exceptions raised to stderr if the --debug + # flag is set + if args.debug: + traceback.print_exc() + raise finally: if profile: trace_id = osprofiler_profiler.get().get_base_id() |