From 6acdcaab6a0a0c783161f0fb7b86a0bcb62afc45 Mon Sep 17 00:00:00 2001 From: Cassandra de la Cruz-Munoz Date: Sun, 31 Dec 2023 12:13:09 -0500 Subject: [PATCH] use custom errors in VmcExtVrm --- src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 903718c..310ba9a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -980,25 +980,25 @@ impl MessageBehavior for VmcExtVrm { args, }; } - fn from_osc_message(msg: OscMessage) -> Result { + fn from_osc_message(msg: OscMessage) -> Result { if msg.args.len() < 2 || msg.args.len() > 3 { - return Err(String::from("arg count invalid")); + return Err(FromMessageErr::ArgCount(ArgCountErr { expected_in: vec![2, 3], actual: msg.args.len(), addr: msg.addr})); } let path: String; let title: String; let mut hash: Option = None; match &msg.args[0] { OscType::String(s) => 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})), } match &msg.args[1] { OscType::String(s) => title = 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})), } if msg.args.len() == 3 { match &msg.args[2] { OscType::String(s) => hash = Some(s.to_owned()), - _ => return Err(String::from("arg type invalid")), + _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: OscType::String(String::new()), actual: msg.args[2], addr: msg.addr, arg_count: 2})), } } return Ok(VmcExtVrm { path, title, hash });