custom message parsing errors #1
|
@ -1020,19 +1020,19 @@ impl MessageBehavior for VmcExtRemote {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
fn from_osc_message(msg: OscMessage) -> Result<Self, String> {
|
fn from_osc_message(msg: OscMessage) -> Result<Self, FromMessageErr> {
|
||||||
if msg.args.len() != 2 {
|
if msg.args.len() != 2 {
|
||||||
return Err(String::from("arg count invalid"));
|
return Err(FromMessageErr::ArgCount(ArgCountErr { expected_in: vec![2], actual: msg.args.len(), addr: msg.addr}));
|
||||||
}
|
}
|
||||||
let service: String;
|
let service: String;
|
||||||
let json: String;
|
let json: String;
|
||||||
match &msg.args[0] {
|
match &msg.args[0] {
|
||||||
OscType::String(s) => service = s.to_owned(),
|
OscType::String(s) => service = 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})),
|
||||||
}
|
}
|
||||||
match &msg.args[1] {
|
match &msg.args[1] {
|
||||||
OscType::String(s) => json = s.to_owned(),
|
OscType::String(s) => json = s.to_owned(),
|
||||||
_ => return Err(String::from("arg type invalid")),
|
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: OscType::String(String::new()), actual: msg.args[1], addr: msg.addr, arg_count: 1})),
|
||||||
}
|
}
|
||||||
return Ok(VmcExtRemote { service, json });
|
return Ok(VmcExtRemote { service, json });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user