From 88cbfb0ec9f98ebdff1e6618cae4ad002ed16064 Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Tue, 22 Oct 2024 14:07:59 +0200 Subject: [PATCH] fix: replace `unwrap` with proper error handling --- crates/bitwarden-wasm-internal/build.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/bitwarden-wasm-internal/build.rs b/crates/bitwarden-wasm-internal/build.rs index b33ca401..7df4fb42 100644 --- a/crates/bitwarden-wasm-internal/build.rs +++ b/crates/bitwarden-wasm-internal/build.rs @@ -11,12 +11,15 @@ fn main() { } fn run(args: &[&str]) -> Result { + 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