From 08163c62511f46b7e6a721034c68cc710852227d Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Mon, 2 Apr 2012 12:33:46 -0400 Subject: [PATCH] catch all exceptions and emit sensible errors - if we have a config file error this lets us know about it --- library/yum | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/library/yum b/library/yum index d5a757dc59..4e46365fce 100755 --- a/library/yum +++ b/library/yum @@ -311,16 +311,23 @@ def main(): if 'list' in params: - my = yum_base(conf_file=params['conf_file'], cachedir=True) - results = dict(results=list_stuff(my, params['list'])) + try: + my = yum_base(conf_file=params['conf_file'], cachedir=True) + results = dict(results=list_stuff(my, params['list'])) + except Exception, e: + return 1, str(e) + elif 'state' in params: if 'pkg' not in params: results['msg'] = "No pkg specified" else: - my = yum_base(conf_file=params['conf_file'], cachedir=True) - state = params['state'] - pkgspec = params['pkg'] - results = ensure(my, state, pkgspec) + try: + my = yum_base(conf_file=params['conf_file'], cachedir=True) + state = params['state'] + pkgspec = params['pkg'] + results = ensure(my, state, pkgspec) + except Exception, e: + return 1, str(e) print json.dumps(results) return 0, None