Skip to content

Commit d0a68cb

Browse files
author
Dan Wendlandt
committed
Fix quantum client exception when server returns 500 error.
bug 963494 Also, make sure that exceptions within the client are accompanied with a full stack trace, otherwise it is hard to track down where it happened. Change-Id: Ic134ed27523b2c321dcb8e35e6ab0eb144a699f3
1 parent 0636609 commit d0a68cb

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

quantum/client/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ def exception_handler_v11(status_code, error_content):
115115
message=error_message)],)
116116
raise ex
117117
# If we end up here the exception was not a quantum error
118-
raise exceptions.QuantumClientException(status_code + "-" + error_content)
118+
msg = "%s-%s" % (status_code, error_content)
119+
raise exceptions.QuantumClientException(message=msg)
119120

120121

121122
EXCEPTION_HANDLERS = {

quantum/client/cli_lib.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import logging
2424
import os
2525
import sys
26+
import traceback
2627

2728
FORMAT = "json"
2829
LOG = logging.getLogger('quantum.client.cli_lib')
@@ -192,7 +193,6 @@ def __init__(self, cmd, data, version):
192193

193194

194195
def _handle_exception(ex):
195-
LOG.exception(sys.exc_info())
196196
status_code = None
197197
message = None
198198
# Retrieve dict at 1st element of tuple at last argument
@@ -202,12 +202,10 @@ def _handle_exception(ex):
202202
msg_1 = "Command failed with error code: %s" \
203203
% (status_code or '<missing>')
204204
msg_2 = "Error message:%s" % (message or '<missing>')
205-
LOG.exception(msg_1 + "-" + msg_2)
206205
print msg_1
207206
print msg_2
208207
else:
209-
print "An unexpected exception occured:%s (%s)" % (sys.exc_info()[1],
210-
sys.exc_info()[0])
208+
traceback.print_exc()
211209

212210

213211
def prepare_output(cmd, tenant_id, response, version):

0 commit comments

Comments
 (0)