diff --git a/fig/cli/command.py b/fig/cli/command.py index d4eb8d67c..62a8a6f1a 100644 --- a/fig/cli/command.py +++ b/fig/cli/command.py @@ -50,11 +50,8 @@ class Command(DocoptCommand): except IOError as e: if e.errno == errno.ENOENT: - log.error("Can't find %s. Are you in the right directory?", os.path.basename(e.filename)) - else: - log.error(e) - - sys.exit(1) + raise errors.FigFileNotFound(os.path.basename(e.filename)) + raise errors.UserError(six.text_type(e)) try: return Project.from_config(self.project_name, config, self.client) diff --git a/fig/cli/errors.py b/fig/cli/errors.py index 02ffe7b62..db39f12e7 100644 --- a/fig/cli/errors.py +++ b/fig/cli/errors.py @@ -51,3 +51,10 @@ Couldn't connect to Docker daemon at %s - is it running? If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable. """ % url) + + +class FigFileNotFound(UserError): + def __init__(self, filename): + super(FigFileNotFound, self).__init__(""" +Can't find %s. Are you in the right directory? +""" % filename)