Update composer-cli for the new error return types.
(cherry picked from commit bc96f75992
)
This commit is contained in:
parent
90aa81e964
commit
6b36d2a188
@ -59,7 +59,7 @@ def handle_api_result(result, show_json=False):
|
||||
:param result: JSON result from the http query
|
||||
:type result: dict
|
||||
:rtype: tuple
|
||||
:returns: (rc, errors)
|
||||
:returns: (rc, should_exit_now)
|
||||
|
||||
Return the correct rc for the program (0 or 1), and whether or
|
||||
not to continue processing the results.
|
||||
@ -68,7 +68,7 @@ def handle_api_result(result, show_json=False):
|
||||
print(json.dumps(result, indent=4))
|
||||
else:
|
||||
for err in result.get("errors", []):
|
||||
log.error(err)
|
||||
log.error(err["msg"])
|
||||
|
||||
# What's the rc? If status is present, use that
|
||||
# If not, use length of errors
|
||||
|
@ -50,7 +50,8 @@ def get_url_raw(socket_path, url):
|
||||
if r.status == 400:
|
||||
err = json.loads(r.data.decode("utf-8"))
|
||||
if "status" in err and err["status"] == False:
|
||||
raise RuntimeError(", ".join(err["errors"]))
|
||||
msgs = [e["msg"] for e in err["errors"]]
|
||||
raise RuntimeError(", ".join(msgs))
|
||||
|
||||
return r.data.decode('utf-8')
|
||||
|
||||
@ -172,7 +173,8 @@ def download_file(socket_path, url, progress=True):
|
||||
if r.status == 400:
|
||||
err = json.loads(r.data.decode("utf-8"))
|
||||
if not err["status"]:
|
||||
raise RuntimeError(", ".join(err["errors"]))
|
||||
msgs = [e["msg"] for e in err["errors"]]
|
||||
raise RuntimeError(", ".join(msgs))
|
||||
|
||||
filename = get_filename(r.headers)
|
||||
if os.path.exists(filename):
|
||||
|
Loading…
Reference in New Issue
Block a user