Skip to content

Commit

Permalink
Fix "throw error instead of panicking"
Browse files Browse the repository at this point in the history
  • Loading branch information
oxc committed Oct 15, 2020
1 parent 70117aa commit d31b28e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/interface/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
},
})
}
Expand Down
2 changes: 2 additions & 0 deletions src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
Expand Down

0 comments on commit d31b28e

Please sign in to comment.