Exception handling when file-not-found

Added rudimentary exception handling for when yaml_fs encounters
a node/class for which no file exists.

Unfortunately, there is no way to properly communicate that to Ansible
when it invokes the adapter. Oh well.

Signed-off-by: martin f. krafft <madduck@madduck.net>
diff --git a/reclass.py b/reclass.py
index f0c24ce..cd44652 100755
--- a/reclass.py
+++ b/reclass.py
@@ -17,6 +17,7 @@
 import config
 from output import OutputLoader
 from storage import StorageBackendLoader
+import errors
 
 def get_options(config_file=None):
     return config.get_options(__name__, __version__, __description__, config_file)
@@ -38,6 +39,10 @@
     outputter = output_class()
     return outputter.dump(data, pretty_print=pretty_print)
 
+def _error(msg, rc):
+    print >>sys.stderr, msg
+    sys.exit(rc)
+
 if __name__ == '__main__':
     __name__ = __prog__
     config_file = None
@@ -46,8 +51,12 @@
         if os.access(f, os.R_OK):
             config_file = f
             break
-    options = get_options(config_file)
-    data = get_data(options.storage_type, options.nodes_uri,
-                    options.classes_uri, options.node)
-    print output(data, options.output, options.pretty_print)
-    sys.exit(posix.EX_OK)
+    try:
+        options = get_options(config_file)
+        data = get_data(options.storage_type, options.nodes_uri,
+                        options.classes_uri, options.node)
+        print output(data, options.output, options.pretty_print)
+        sys.exit(posix.EX_OK)
+
+    except errors.ReclassException, e:
+        _error(e.message, e.rc)