From 9aa00b5b366320eed6e9f0d16a63fa3fafcc866d Mon Sep 17 00:00:00 2001 From: Cassandra de la Cruz-Munoz Date: Sun, 31 Dec 2023 12:24:28 -0500 Subject: [PATCH] use custom errors in VmcExtSetPeriod --- src/lib.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 49ac8cc..c04b798 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1263,9 +1263,9 @@ impl MessageBehavior for VmcExtSetPeriod { OscType::from(self.devices), ] }; } - fn from_osc_message(msg: OscMessage) -> Result { + fn from_osc_message(msg: OscMessage) -> Result { if msg.args.len() != 6 { - return Err(String::from("arg count invalid")); + return Err(FromMessageErr::ArgCount(ArgCountErr { expected_in: vec![6], actual: msg.args.len(), addr: msg.addr})); } let status: i32; let root: i32; @@ -1275,27 +1275,27 @@ impl MessageBehavior for VmcExtSetPeriod { let devices: i32; match msg.args[0] { OscType::Int(i) => status = i, - _ => return Err(String::from("arg type invalid")) + _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[0], addr: msg.addr, arg_count: 0})) } match msg.args[1] { OscType::Int(i) => root = i, - _ => return Err(String::from("arg type invalid")) + _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[1], addr: msg.addr, arg_count: 1})) } match msg.args[2] { OscType::Int(i) => bone = i, - _ => return Err(String::from("arg type invalid")) + _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[2], addr: msg.addr, arg_count: 2})) } match msg.args[3] { OscType::Int(i) => blendshape = i, - _ => return Err(String::from("arg type invalid")) + _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[3], addr: msg.addr, arg_count: 3})) } match msg.args[4] { OscType::Int(i) => camera = i, - _ => return Err(String::from("arg type invalid")) + _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[4], addr: msg.addr, arg_count: 4})) } match msg.args[5] { OscType::Int(i) => devices = i, - _ => return Err(String::from("arg type invalid")) + _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[5], addr: msg.addr, arg_count: 5})) } return Ok(VmcExtSetPeriod { status, root, bone, blendshape, camera, devices}) }