custom message parsing errors #1

Merged
cassdlcm merged 22 commits from custom_errors into main 2023-12-31 19:36:26 +01:00
Showing only changes of commit 3fab3f9a2e - Show all commits

View File

@ -1187,13 +1187,13 @@ impl MessageBehavior for VmcExtConfig {
args: vec![OscType::from(self.path.to_owned())],
};
}
fn from_osc_message(msg: OscMessage) -> Result<Self, String> {
if msg.addr.len() != 1 {
return Err(String::from("arg count invalid"));
fn from_osc_message(msg: OscMessage) -> Result<Self, FromMessageErr> {
if msg.args.len() != 1 {
return Err(FromMessageErr::ArgCount(ArgCountErr { expected_in: vec![1], actual: msg.args.len(), addr: msg.addr }));
}
match &msg.args[0] {
OscType::String(s) => return Ok(VmcExtConfig { path: s.to_owned() }),
_ => return Err(String::from("arg type invalid")),
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: OscType::String(String::new()), actual: msg.args[0], addr: msg.addr, arg_count: 0})),
}
}
}