changeset 623:03167105f6de rust

ignore missing local.conf
author Matt Johnston <matt@ucc.asn.au>
date Sun, 16 Apr 2017 22:50:20 +0800
parents 5b456905eaac
children 2710649ab71e
files rust/src/main.rs rust/src/types.rs
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rust/src/main.rs	Sun Apr 16 22:50:05 2017 +0800
+++ b/rust/src/main.rs	Sun Apr 16 22:50:20 2017 +0800
@@ -8,6 +8,7 @@
 extern crate tokio_curl;
 extern crate curl;
 extern crate serde_json;
+extern crate libc;
 
 #[macro_use] 
 extern crate lazy_static;
@@ -151,6 +152,14 @@
     let conf_filename = "local.conf";
     nconfig.merge_file(conf_filename)
         .unwrap_or_else(|e| {
+            if let TemplogErrorKind::Io(ref ioe) = *e.kind() {
+                if let Some(errno) = ioe.raw_os_error() {
+                    if errno == libc::ENOENT {
+                        return nconfig;
+                    }
+                }
+            }
+
             println!("Couldn't parse {}: {}", conf_filename, e);
             std::process::exit(1);
     })
--- a/rust/src/types.rs	Sun Apr 16 22:50:05 2017 +0800
+++ b/rust/src/types.rs	Sun Apr 16 22:50:20 2017 +0800
@@ -113,6 +113,10 @@
         TemplogError::new_kind(msg, TemplogErrorKind::SerdeJson(e))
     }
 
+    pub fn kind(&self) -> &TemplogErrorKind {
+        return &self.kind;
+    }
+
     fn new_kind(msg: &str, k: TemplogErrorKind) -> Self {
         let mut s = TemplogError { 
             msg: msg.to_string(),