瀏覽代碼

Emit a friendly error when fig.yml is missing

I keep doing this by accident, so I'd rather not see the stack trace.
Tom Stuart 11 年之前
父節點
當前提交
490742b892
共有 1 個文件被更改,包括 11 次插入1 次删除
  1. 11 1
      fig/cli/command.py

+ 11 - 1
fig/cli/command.py

@@ -1,4 +1,5 @@
 from docker import Client
+import errno
 import logging
 import os
 import re
@@ -18,7 +19,16 @@ class Command(DocoptCommand):
 
     @cached_property
     def project(self):
-        config = yaml.load(open('fig.yml'))
+        try:
+            config = yaml.load(open('fig.yml'))
+        except IOError, e:
+            if e.errno == errno.ENOENT:
+                log.error("Can't find %s. Are you in the right directory?", e.filename)
+            else:
+                log.error(e)
+
+            exit(1)
+
         return Project.from_config(self.project_name, config, self.client)
 
     @cached_property