Skip to content

Commit

Permalink
fix: replace unwrap with proper error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
coroiu committed Oct 23, 2024
1 parent 7f105f5 commit 88cbfb0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/bitwarden-wasm-internal/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ fn main() {
}

fn run(args: &[&str]) -> Result<String, std::io::Error> {
use std::io::{Error, ErrorKind};
let out = Command::new(args[0]).args(&args[1..]).output()?;
if !out.status.success() {
use std::io::{Error, ErrorKind};
return Err(Error::new(ErrorKind::Other, "Command not successful"));
}
Ok(String::from_utf8(out.stdout).unwrap().trim().to_string())
Ok(String::from_utf8(out.stdout)
.map_err(|e| Error::new(ErrorKind::Other, e.to_string()))?
.trim()
.to_string())
}

/// This method reads info from Git, namely tags, branch, and revision
Expand Down

0 comments on commit 88cbfb0

Please sign in to comment.