diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-09-21 13:03:10 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-09-21 16:02:26 +0100 |
commit | f074540a2789af71d0e5c74eac9543ce67d63acc (patch) | |
tree | f88830acc4030b259c78bcbd7a781bed36e0dd88 /morphlib/plugins | |
parent | 12f27c2ecf231c9659797f116a3217474742f609 (diff) | |
download | morph-f074540a2789af71d0e5c74eac9543ce67d63acc.tar.gz |
Give better error when reading a morphology file fails
Also remove a spurious warning.
Longer term, this git access code should be moved to a Repo class
which can be shared with the rest of Morph and provide more granular
exceptions on failure.
Diffstat (limited to 'morphlib/plugins')
-rw-r--r-- | morphlib/plugins/branch_and_merge_plugin.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py index c7bcedfb..32fb1c8c 100644 --- a/morphlib/plugins/branch_and_merge_plugin.py +++ b/morphlib/plugins/branch_and_merge_plugin.py @@ -224,10 +224,15 @@ class BranchAndMergePlugin(cliapp.Plugin): text = f.read() else: ref = morphlib.git.find_first_ref(self.app.runcmd, repo_dir, ref) - logging.warning("Running git cat-file blob %s:%s.morph in %s" % ( - ref, name, repo_dir)) - text = self.app.runcmd(['git', 'cat-file', 'blob', - '%s:%s.morph' % (ref, name)], cwd=repo_dir) + try: + text = self.app.runcmd(['git', 'cat-file', 'blob', + '%s:%s.morph' % (ref, name)], + cwd=repo_dir) + except cliapp.AppException as e: + msg = '%s.morph was not found in %s' % (name, repo_dir) + if ref is not None: + msg += ' at ref %s' % ref + raise cliapp.AppException(msg) morphology = morphlib.morph2.Morphology(text) return morphology |