From a91a39ecbe6b2d00b09b6d857ae991c8e2de3927 Mon Sep 17 00:00:00 2001 From: Cassandra de la Cruz-Munoz Date: Sun, 31 Dec 2023 12:13:48 -0500 Subject: [PATCH] use custom errors in VmcExtRemote --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 310ba9a..a542588 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1020,19 +1020,19 @@ impl MessageBehavior for VmcExtRemote { ], }; } - fn from_osc_message(msg: OscMessage) -> Result { + fn from_osc_message(msg: OscMessage) -> Result { 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 json: String; match &msg.args[0] { 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] { 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 }); }