mirror of
https://github.com/aramperes/nut-rs.git
synced 2025-09-09 21:38:30 -04:00
Simplify errors
This commit is contained in:
parent
c935d88496
commit
96fbfeaeab
8 changed files with 109 additions and 135 deletions
|
@ -200,17 +200,13 @@ impl TryFrom<&str> for VariableType {
|
|||
.nth(1)
|
||||
.map(|s| s.parse().ok())
|
||||
.flatten()
|
||||
.ok_or_else(|| {
|
||||
crate::ClientError::Nut(crate::NutError::Generic(
|
||||
"Invalid STRING definition".into(),
|
||||
))
|
||||
})?;
|
||||
.ok_or_else(|| crate::ClientError::generic("Invalid STRING definition"))?;
|
||||
Ok(Self::String(size))
|
||||
} else {
|
||||
Err(crate::ClientError::Nut(crate::NutError::Generic(format!(
|
||||
Err(crate::ClientError::generic(format!(
|
||||
"Unrecognized variable type: {}",
|
||||
value
|
||||
))))
|
||||
)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue