use custom errors in VmcExtMidiCcVal
This commit is contained in:
parent
c0645d9282
commit
75a541cc2a
|
@ -671,19 +671,19 @@ impl MessageBehavior for VmcExtMidiCcVal {
|
|||
args: vec![OscType::from(self.knob), OscType::from(self.value)],
|
||||
};
|
||||
}
|
||||
fn from_osc_message(msg: OscMessage) -> Result<Self, String> {
|
||||
fn from_osc_message(msg: OscMessage) -> Result<Self, FromMessageErr> {
|
||||
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 knob: i32;
|
||||
let value: f32;
|
||||
match msg.args[0] {
|
||||
OscType::Int(i) => knob = i,
|
||||
_ => return Err(String::from("arg type invalid")),
|
||||
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: OscType::Int(0), actual: msg.args[0], addr: msg.addr, arg_count: 0})),
|
||||
}
|
||||
match msg.args[1] {
|
||||
OscType::Float(f) => value = f,
|
||||
_ => return Err(String::from("arg type invalid")),
|
||||
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: OscType::Float(0.0), actual: msg.args[1], addr: msg.addr, arg_count: 1})),
|
||||
}
|
||||
return Ok(VmcExtMidiCcVal { knob, value });
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user