Skip to content

Commit

Permalink
Better error printing
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaves committed Jun 17, 2020
1 parent 3462a9c commit 6e666f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/bluetooth/bluetooth_receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ impl BluetoothReceiver {
break;
}
};
if verbose >= 3 {
eprintln!("Ready fds: {:?}", ready);
}
let mut msgs = Vec::new();
for fd_idx in ready {
let (v, l) = ecp_service
Expand Down Expand Up @@ -193,13 +196,18 @@ impl BluetoothReceiver {
}
}
}
if msgs.len() == 0 {
if verbose >= 3 {
eprintln!("LedMsgs to be send: {:?}", msgs);
}
if let Err(e) = send_msgs.try_send(RecvMsg::LedMsgs(msgs)) {
if let mpsc::TrySendError::Disconnected(_) = e {
return Err(Error::Unrecoverable(
"Receiver is disconnected".to_string(),
));
}
}
}
}
}
}));
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ impl LedMsg {
Command::FlatStack(*buf.get(i + 3 + extra0).ok_or_else(extra_bytes)?),
1,
),

_ => unreachable!(),
v => return Err(Error::BadInput(format!("Unknown command was given: {:#04X}", v)))
};
let msg = LedMsg {
cur_time,
Expand Down

0 comments on commit 6e666f8

Please sign in to comment.