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
26
27
use errors::{Result, Error};
use std::fs::File;
use std::path::Path;
use failure::Fail;
pub fn create_file(path: &Path) -> Result<File> {
if let Some(p) = path.parent() {
::std::fs::create_dir_all(p)?;
}
Ok(File::create(path)?)
}
pub fn print_error(err: &Error) {
eprintln!("error: {}", err);
for cause in err.causes() {
eprintln!("{}", cause);
}
if let Some(backtrace) = err.backtrace() {
eprintln!("backtrace: {:?}", backtrace);
}
}