Return error for env vars instead of panic
authorJacob Casper <dev@jacobcasper.com>
Sat, 25 Apr 2020 01:59:40 +0000 (20:59 -0500)
committerJacob Casper <dev@jacobcasper.com>
Sat, 25 Apr 2020 02:54:57 +0000 (21:54 -0500)
src/main.rs

index a783233..bc758e4 100644 (file)
@@ -33,9 +33,9 @@ fn main() -> Result<(), Box<dyn error::Error>> {
 
             let repo = git2::Repository::init_opts(format!("{}.git", repo_name), &opts)?;
 
-            let public_user = env::var("USER").unwrap();
-            let public_name = env::var("PUBLIC").unwrap();
-            let public_path = env::var("PATH").unwrap();
+            let public_user = env::var("USER")?;
+            let public_name = env::var("PUBLIC")?;
+            let public_path = env::var("PATH")?;
             repo.remote(
                 &public_name,
                 &format!(