diff --git a/git-cliff-core/src/embed.rs b/git-cliff-core/src/embed.rs index 075299789f..d07b24efd2 100644 --- a/git-cliff-core/src/embed.rs +++ b/git-cliff-core/src/embed.rs @@ -21,7 +21,7 @@ impl EmbeddedConfig { /// Extracts the embedded content. pub fn get_config() -> Result { match Self::get(crate::DEFAULT_CONFIG) { - Some(v) => Ok(str::from_utf8(&v.data.into_owned()).unwrap().to_string()), + Some(v) => Ok(str::from_utf8(&v.data.into_owned())?.to_string()), None => Err(Error::EmbeddedError(String::from( "Embedded config not found", ))), diff --git a/git-cliff-core/src/error.rs b/git-cliff-core/src/error.rs index 29170fc19c..3c5ed66eed 100644 --- a/git-cliff-core/src/error.rs +++ b/git-cliff-core/src/error.rs @@ -6,6 +6,10 @@ pub enum Error { /// Error that may occur while I/O operations. #[error("IO error: `{0}`")] IoError(#[from] std::io::Error), + /// Error that may occur when attempting to interpret a sequence of u8 as a + /// string. + #[error("UTF-8 error: `{0}`")] + Utf8Error(#[from] std::str::Utf8Error), /// Error variant that represents errors coming out of libgit2. #[error("Git error: `{0}`")] GitError(#[from] git2::Error),