From 3f01f2f3fdde35c3135a4b249c9e1e9f81e0928c Mon Sep 17 00:00:00 2001 From: Cassandra de la Cruz-Munoz Date: Sun, 31 Dec 2023 13:18:47 -0500 Subject: [PATCH] use custom errors in VmcExtSetEye --- src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c04b798..1306a0f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1316,9 +1316,9 @@ impl MessageBehavior for VmcExtSetEye { ] }; } - fn from_osc_message(msg: OscMessage) -> Result { + fn from_osc_message(msg: OscMessage) -> Result { if msg.args.len() != 4 { - return Err(String::from("arg count invalid")); + return Err(FromMessageErr::ArgCount(ArgCountErr { expected_in: vec![4], actual: msg.args.len(), addr: msg.addr})); } let enable: i32; let x: f32; @@ -1326,20 +1326,20 @@ impl MessageBehavior for VmcExtSetEye { let z: f32; match msg.args[0] { OscType::Int(i) => enable = 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::Float(f) => x = f, - _ => return Err(String::from("arg type invalid")), + _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[1], addr: msg.addr, arg_count: 1})) } match msg.args[2] { OscType::Float(f) => y = f, - _ => return Err(String::from("arg type invalid")), + _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[2], addr: msg.addr, arg_count: 2})) } match msg.args[3] { OscType::Float(f) => z = f, - _ => return Err(String::from("arg type invalid")), + _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[3], addr: msg.addr, arg_count: 3})) } return Ok(VmcExtSetEye { enable, position: Vector3::new(x, y, z)}) }