Better error handling.

This commit is contained in:
Nicolás A. Ortega Froysa 2022-07-08 13:47:08 +02:00
parent 64af383fc6
commit 1d61c2b439

View File

@ -74,11 +74,10 @@ fn main()
let opts = Opts::from_args(); let opts = Opts::from_args();
let mut hmgr = HabitMgr::new(); let mut hmgr = HabitMgr::new();
let mut data_dir = PathBuf::from( let data_dir:PathBuf = match env::var("XDG_DATA_HOME") {
env::var("XDG_DATA_HOME") Ok(s) => [ s, "htracker".to_string() ].iter().collect(),
.unwrap_or("./".to_string())); Err(_e) => PathBuf::from("./"),
// TODO: don't add this if we use ./ };
data_dir.push("htracker");
if !data_dir.exists() if !data_dir.exists()
{ {