diff --git a/rust/src/nasl/builtin/cryptographic/hash.rs b/rust/src/nasl/builtin/cryptographic/hash.rs index 5289e0033..63d02ab4d 100644 --- a/rust/src/nasl/builtin/cryptographic/hash.rs +++ b/rust/src/nasl/builtin/cryptographic/hash.rs @@ -15,6 +15,8 @@ use sha2::{Sha256, Sha512}; use crate::nasl::syntax::NaslValue; use crate::nasl::utils::{Context, Register}; +use super::ArgumentError; + fn nasl_hash(register: &Register) -> Result where D::OutputSize: std::ops::Add, @@ -28,7 +30,7 @@ where NaslValue::String(x) => x.as_bytes(), NaslValue::Data(x) => x, NaslValue::Null => return Ok(NaslValue::Null), - x => return Err(("data", "string", x).into()), + x => return Err(ArgumentError::wrong_argument("data", "string", &x.to_string()).into()), }; let mut hash = D::new(); diff --git a/rust/src/nasl/utils/error.rs b/rust/src/nasl/utils/error.rs index d699ff002..13b4dce8d 100644 --- a/rust/src/nasl/utils/error.rs +++ b/rust/src/nasl/utils/error.rs @@ -128,20 +128,3 @@ impl FunctionErrorKind { Self::Argument(ArgumentError::MissingNamed(vec![val.to_string()])) } } - -impl From<(&str, &str, &NaslValue)> for FunctionErrorKind { - fn from(value: (&str, &str, &NaslValue)) -> Self { - let (key, expected, got) = value; - let got: &str = &got.to_string(); - ArgumentError::wrong_argument(key, expected, got).into() - } -} - -impl From<(&str, &str, Option<&NaslValue>)> for FunctionErrorKind { - fn from(value: (&str, &str, Option<&NaslValue>)) -> Self { - match value { - (key, expected, Some(x)) => (key, expected, x).into(), - (key, expected, None) => ArgumentError::wrong_argument(key, expected, "NULL").into(), - } - } -}