mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
better error handling
This commit is contained in:
@@ -357,8 +357,9 @@ class ExecutableJsonLoader(BaseLoader):
|
|||||||
stdout, stderr = proc.communicate()
|
stdout, stderr = proc.communicate()
|
||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
raise RuntimeError('%r failed (rc=%d) with output: %s' % (cmd, proc.returncode, stderr))
|
raise RuntimeError('%r failed (rc=%d) with output: %s' % (cmd, proc.returncode, stderr))
|
||||||
data = json.loads(stdout)
|
try:
|
||||||
if not isinstance(data, dict):
|
data = json.loads(stdout)
|
||||||
|
except ValueError:
|
||||||
raise TypeError('Returned JSON must be a dictionary, got %s instead' % str(type(data)))
|
raise TypeError('Returned JSON must be a dictionary, got %s instead' % str(type(data)))
|
||||||
except:
|
except:
|
||||||
logger.error('Failed to load JSON from: %s', stdout)
|
logger.error('Failed to load JSON from: %s', stdout)
|
||||||
|
|||||||
Reference in New Issue
Block a user