diff --git a/src/interface/response.rs b/src/interface/response.rs index 8500a80..a1a6bfd 100644 --- a/src/interface/response.rs +++ b/src/interface/response.rs @@ -219,7 +219,7 @@ impl Response { 0x0026 => Event::PhyConfigChanged { selected_phys: BitFlags::from_bits_truncate(buf.get_u32_le()), }, - _ => todo!("throw error instead of panicking"), + _ => return Err(Error::UnknownEventCode { evt_code }), }, }) } diff --git a/src/result.rs b/src/result.rs index 852eae6..89eaad3 100644 --- a/src/result.rs +++ b/src/result.rs @@ -22,6 +22,8 @@ pub enum Error { UnknownOpcode { opcode: u16 }, #[error("Unknown command status: {:x}.", status)] UnknownStatus { status: u8 }, + #[error("Unknown event code: {:x}.", evt_code)] + UnknownEventCode { evt_code: u16 }, #[error("Timed out.")] TimedOut, #[error("The socket received invalid data.")]