dcos-1886 don't crash if invalid json commands
This commit is contained in:
@@ -361,6 +361,16 @@ def test_update_bad_type():
|
||||
assert stdout == b''
|
||||
|
||||
|
||||
def test_update_invalid_request():
|
||||
returncode, stdout, stderr = exec_command(
|
||||
['dcos', 'marathon', 'app', 'update', '{', 'instances'])
|
||||
assert returncode == 1
|
||||
assert stdout == b''
|
||||
stderr = stderr.decode()
|
||||
assert stderr.startswith('Error while fetching')
|
||||
assert stderr.endswith('HTTP 400: Bad Request\n')
|
||||
|
||||
|
||||
def test_update_app():
|
||||
with _zero_instance_app():
|
||||
returncode, stdout, stderr = exec_command(
|
||||
|
||||
@@ -54,6 +54,11 @@ def _to_exception(response):
|
||||
if isinstance(response, Exception):
|
||||
return DCOSException(_default_marathon_error(str(response)))
|
||||
|
||||
if response.status_code == 400:
|
||||
return DCOSException(
|
||||
'Error while fetching [{0}]: HTTP {1}: {2}'.format(
|
||||
response.request.url, response.status_code, response.reason))
|
||||
|
||||
message = response.json().get('message')
|
||||
if message is None:
|
||||
errs = response.json().get('errors')
|
||||
|
||||
Reference in New Issue
Block a user