Skip to content

Commit

Permalink
Consolidate 'ParameterNotSet' into 'ParamterWrongType' error
Browse files Browse the repository at this point in the history
  • Loading branch information
IamTheCarl committed Oct 9, 2024
1 parent a7093a8 commit e2b68c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
3 changes: 0 additions & 3 deletions r2r/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ pub enum Error {
#[error("Parameter {name} conversion failed: {msg}")]
ParameterValueConv { name: String, msg: String },

#[error("Expected parameter {name} is not set")]
ParameterNotSet { name: String },

#[error(
"Parameter {name} was expected to be of type {expected_type} but was of type {actual_type}"
)]
Expand Down
11 changes: 5 additions & 6 deletions r2r/src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,14 +547,13 @@ impl Node {
ParameterValue: TryInto<T, Error = WrongParameterType>,
{
let params = self.params.lock().unwrap();
let parameter = params.get(name).ok_or(Error::ParameterNotSet {
name: name.to_string(),
})?;
let value = params
.get(name)
.map(|parameter| parameter.value.clone())
.unwrap_or(ParameterValue::NotSet);

let value: T =
parameter
.value
.clone()
value
.try_into()
.map_err(|error: WrongParameterType| Error::ParameterWrongType {
name: name.to_string(),
Expand Down

0 comments on commit e2b68c9

Please sign in to comment.