diff options
| author | Teddy Wing | 2020-09-17 00:34:44 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2020-09-17 00:34:44 +0200 | 
| commit | 0c0072f1cd16850c648bd5ccd694971e4e24f5b4 (patch) | |
| tree | d6109b0cf4faf57be22ddcb87e2e2e8699f7bd22 /src | |
| parent | ce270ba827ceb435b021c5055b6796d426ce7bdc (diff) | |
| download | git-todo-0c0072f1cd16850c648bd5ccd694971e4e24f5b4.tar.bz2 | |
main.rs: Remove `unwrap()`s and handle errors
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 16 | 
1 files changed, 14 insertions, 2 deletions
| diff --git a/src/main.rs b/src/main.rs index cb3b77c..780ab62 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,13 @@ fn main() {          },      }; -    let repo = Repository::open(".").unwrap(); +    let repo = match Repository::open(".") { +        Ok(r) => r, +        Err(e) => { +            eprintln(&format!("unable to open repository: {}", e)); +            process::exit(exitcode::NOINPUT); +        }, +    };      let todos = Todos { repo: &repo }; @@ -55,7 +61,13 @@ fn main() {          }      }; -    todos.write_since(tree, &mut std::io::stdout()).unwrap(); +    match todos.write_since(tree, &mut std::io::stdout()) { +        Err(e) => { +            eprintln(&e); +            process::exit(exitcode::UNAVAILABLE); +        }, +        _ => (), +    };  }  /// Print to standard error with a program-specific prefix. | 
