Skip to content

Commit

Permalink
Merge pull request #1784 from greenbone/improve-openvasd-error-messages
Browse files Browse the repository at this point in the history
Improve various error messages
  • Loading branch information
Tehforsch authored Jan 9, 2025
2 parents cf28b04 + bb41ead commit 9d3cb04
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions rust/src/feed/verify/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub enum Error {
#[error("Incorrect feed.")]
/// Corrupt sums file
SumsFileCorrupt(Hasher),
#[error("Unable to load the file.")]
#[error("Unable to load file: {0}")]
/// Unable to load the file
LoadError(#[from] LoadError),
#[error("Invalid hash for file with key '{key}'. Expected '{expected}', found '{actual}'.")]
Expand Down Expand Up @@ -164,7 +164,8 @@ where
let helper = VHelper::new(gnupghome);

let sign_path = path.as_ref().to_path_buf().join("sha256sums.asc");
let mut sig_file = File::open(sign_path).unwrap();
let mut sig_file = File::open(&sign_path)
.unwrap_or_else(|e| panic!("Could not find signature at {sign_path:?}. {e}"));
let mut signature = Vec::new();
let _ = sig_file.read_to_end(&mut signature);

Expand Down
5 changes: 3 additions & 2 deletions rust/src/openvasd/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,10 @@ impl Config {

fn from_file<P>(path: P) -> Self
where
P: AsRef<std::path::Path> + std::fmt::Display,
P: AsRef<std::path::Path> + std::fmt::Display + std::fmt::Debug,
{
let config = std::fs::read_to_string(path).unwrap();
let config = std::fs::read_to_string(&path)
.unwrap_or_else(|e| panic!("Failed to read openvasd config from file: {path:?}. {e}"));
toml::from_str(&config).unwrap()
}

Expand Down
2 changes: 1 addition & 1 deletion rust/src/storage/redis/dberror.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl From<RedisError> for DbError {
| ErrorKind::InvalidClientConfig
| ErrorKind::Moved
| ErrorKind::Ask => DbError::ConfigurationError(err.to_string()),
ErrorKind::IoError => DbError::PoisonedLock(err.to_string()),
ErrorKind::IoError => DbError::IoError(err.to_string()),
ErrorKind::TypeError
| ErrorKind::ClientError
| ErrorKind::CrossSlot
Expand Down

0 comments on commit 9d3cb04

Please sign in to comment.