Log error if failed to load config file
authorStiletto <blasux@blasux.ru>
Wed, 24 Oct 2012 00:37:04 +0400
changeset 6 0d97b0d61ed2
parent 5 9574ebf72d81
child 7 a49fb1ec5e2a
Log error if failed to load config file
config.vala
--- a/config.vala	Wed Oct 24 00:36:26 2012 +0400
+++ b/config.vala	Wed Oct 24 00:37:04 2012 +0400
@@ -7,10 +7,12 @@
         base();
         hash = new Gee.HashMap<string,string>();
         IOChannel cfg;
-        /* try { */
+        try {
             cfg = new IOChannel.file(filename,"r");
-        /*} catch (FileError e) {
-            File.new_for_path(filename);*/
+        } catch (FileError e) {
+            log("config", LogLevelFlags.LEVEL_ERROR, "Failed to load config file '%s'", filename);
+            return;
+        }
         string section = "default";
         do {
             string str;
@@ -20,13 +22,11 @@
                 str = str[0:(long)termpos];
                 if ( str.has_prefix("[") && str.has_suffix("]") ) {
                     section = str[1:-1];
-                    stdout.printf("Section '%s'\n",section);
                 } else {
                     string[] parts = str.split("=",2);
                     if (parts.length==2) {
                         var nkey = rkey(section,parts[0]);
                         hash[nkey] = parts[1];
-                        stdout.printf("LOL: key: %s value: %s\n",nkey,parts[1]);
                     }
                 }
             } else