Raise an exception when a non-existent editor is passed

This commit is contained in:
Eric Torres 2019-02-19 16:48:34 -08:00
parent f5f598a020
commit 475eaebd96

View File

@ -50,13 +50,16 @@ def select_editor(editor_override=None):
:rtype: str :rtype: str
:raises: FileNotFoundError if an editor could not be resolved :raises: FileNotFoundError if an editor could not be resolved
""" """
editor = None
if editor_override is not None: if editor_override is not None:
return shutil.which(editor_override) editor = shutil.which(editor_override)
elif 'EDITOR' in os.environ: elif 'EDITOR' in os.environ:
return shutil.which(os.environ.get('EDITOR')) editor = shutil.which(os.environ.get('EDITOR'))
elif shutil.which('vim') is not None: elif shutil.which('vim') is not None:
return shutil.which('vim') editor = shutil.which('vim')
else:
if editor is None:
raise FileNotFoundError('An editor could not be resolved') raise FileNotFoundError('An editor could not be resolved')