Skip to content

Commit

Permalink
Merge pull request #3 from jrwesolo/config_missing_fix
Browse files Browse the repository at this point in the history
fix scope issue with exception handling
  • Loading branch information
jrwesolo committed Jan 21, 2016
2 parents cb39343 + c31a30a commit da287f7
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions bin/yumsync
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,23 @@ def scan_yaml(**rawrepo):

# load configuration
def load_config():
with open(REPOFILE, 'r') as f:
try:
try:
with open(REPOFILE, 'r') as f:
config = yaml.safe_load(f)
if type(config) != dict: raise SyntaxError
return config
except IOError as e:
log("I/O error({0}): {1}".format(e.errno, e.strerror))
sys.exit(1)
except SyntaxError as e:
log('configuration file needs to resolve to a dictionary (hash)')
sys.exit(1)
except yaml.YAMLError as e:
log('unable to parse configuration file')
if hasattr(e, 'problem_mark'):
mark = e.problem_mark
log('Error at Line %d, column %d' % (mark.line+1, mark.column+1))
sys.exit(1)
except IOError as e:
log("I/O error({0}): {1}".format(e.errno, e.strerror))
sys.exit(1)
except SyntaxError as e:
log('configuration file needs to resolve to a dictionary (hash)')
sys.exit(1)
except yaml.YAMLError as e:
log('unable to parse configuration file')
if hasattr(e, 'problem_mark'):
mark = e.problem_mark
log('Error at Line %d, column %d' % (mark.line+1, mark.column+1))
sys.exit(1)

# check repos passed on command line
def check_cmdline_repos(**rawrepo):
Expand Down

0 comments on commit da287f7

Please sign in to comment.