api call error forwarding to cli
* prints api call error along with http error * checks for empty error response body Closes-bug: #1259585 Change-Id: I332fa960d74681610e6cf6b759c9b6bd5f91ec91
This commit is contained in:
parent
66119c3f50
commit
b267a319b2
|
@ -78,7 +78,13 @@ class SetAction(argparse.Action):
|
|||
|
||||
def handle_exceptions(exc):
|
||||
if isinstance(exc, urllib2.HTTPError):
|
||||
print_error(str(exc))
|
||||
error_body = exc.read()
|
||||
print_error("{0} {1}".format(
|
||||
exc,
|
||||
"({0})".format(
|
||||
"" if error_body is None else error_body
|
||||
)
|
||||
))
|
||||
elif isinstance(exc, urllib2.URLError):
|
||||
print_error("Can't connect to Nailgun server!")
|
||||
else:
|
||||
|
@ -488,6 +494,11 @@ def node(params):
|
|||
if not params.node and params.env:
|
||||
node_ids = [k for k, v in nodes_clusters.iteritems()
|
||||
if v == int(params.env)]
|
||||
if not node_ids:
|
||||
print_error(
|
||||
"Environment with id={0} doesn't have nodes to remove."
|
||||
.format(params.env)
|
||||
)
|
||||
else:
|
||||
node_ids = list(chain(*params.node))
|
||||
data = map(
|
||||
|
|
Loading…
Reference in New Issue