1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
use errors::{Result, Error}; use std::fs::File; use std::path::Path; use failure::Fail; /// create the file of `path` /// /// if parent of `path` does not existed, create it first. pub fn create_file(path: &Path) -> Result<File> { if let Some(p) = path.parent() { ::std::fs::create_dir_all(p)?; } Ok(File::create(path)?) } /// log error chain pub fn log_error(err: &Error) { for cause in err.causes() { error!("{}", cause); } if let Some(backtrace) = err.backtrace() { error!("backtrace: {:?}", backtrace); } }