diff --git a/src/serial.rs b/src/serial.rs index fee3279..ebffd69 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -1,4 +1,5 @@ use anyhow::{ + bail, Context, Result, }; @@ -10,7 +11,7 @@ use crate::improv::{ ImprovDataToPacket, }; -pub fn find_begin_of_improv_packet(buffer: &Vec) -> Result { +pub fn find_begin_of_improv_packet(buffer: &Vec) -> Result { let mut improv_header_char: usize = 0; for (i, b) in buffer.iter().enumerate() { @@ -29,7 +30,7 @@ pub fn find_begin_of_improv_packet(buffer: &Vec) -> Result { } } - return Err(String::from("Improv header not found")); + bail!("Improv header not found"); } pub struct SerialInterface {