comparison rust/src/main.rs @ 623:03167105f6de rust

ignore missing local.conf
author Matt Johnston <matt@ucc.asn.au>
date Sun, 16 Apr 2017 22:50:20 +0800
parents 8fda564cc46f
children 2710649ab71e
comparison
equal deleted inserted replaced
622:5b456905eaac 623:03167105f6de
6 extern crate rustc_serialize; 6 extern crate rustc_serialize;
7 extern crate time; 7 extern crate time;
8 extern crate tokio_curl; 8 extern crate tokio_curl;
9 extern crate curl; 9 extern crate curl;
10 extern crate serde_json; 10 extern crate serde_json;
11 extern crate libc;
11 12
12 #[macro_use] 13 #[macro_use]
13 extern crate lazy_static; 14 extern crate lazy_static;
14 15
15 #[macro_use] 16 #[macro_use]
149 let nconfig = config::Config::default(); 150 let nconfig = config::Config::default();
150 151
151 let conf_filename = "local.conf"; 152 let conf_filename = "local.conf";
152 nconfig.merge_file(conf_filename) 153 nconfig.merge_file(conf_filename)
153 .unwrap_or_else(|e| { 154 .unwrap_or_else(|e| {
155 if let TemplogErrorKind::Io(ref ioe) = *e.kind() {
156 if let Some(errno) = ioe.raw_os_error() {
157 if errno == libc::ENOENT {
158 return nconfig;
159 }
160 }
161 }
162
154 println!("Couldn't parse {}: {}", conf_filename, e); 163 println!("Couldn't parse {}: {}", conf_filename, e);
155 std::process::exit(1); 164 std::process::exit(1);
156 }) 165 })
157 } 166 }
158 167