Skip to content

Commit

Permalink
Make the dashboard give a more descriptive error for double-usage of …
Browse files Browse the repository at this point in the history
…its surprise socket, and make it succeed in accepting surprises on the Raspberry Pi as well
  • Loading branch information
CaspianA1 committed Jun 16, 2024
1 parent 4f27ed4 commit c9d9508
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/dashboard_defs/surprise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ pub fn make_surprise_window(
let trigger_appearance_artificially = not_currently_active && {
let mut shared_info = surprise_info.shared_info.borrow_mut();

// TODO: include some error handling here
/* TODO: include some error handling here (should I care
about the "resource temporarily unavailable" thing?) */
if let Some(Ok(stream)) = shared_info.surprise_stream_listener.next() {
let mut reader = BufReader::new(stream);
reader.read_line(&mut shared_info.surprise_stream_path_buffer)?;
Expand Down Expand Up @@ -192,7 +193,19 @@ pub fn make_surprise_window(

let options = ListenerOptions::new().name(artificial_triggering_socket_path.to_fs_name::<GenericFilePath>()?);

let surprise_stream_listener = options.create_sync()?;
let surprise_stream_listener = match options.create_sync() {
Ok(listener) => listener,

Err(err) => {
return Err(format!(
"Could not create a surprise stream listener. \
Perhaps the socket at '{artificial_triggering_socket_path}' is already in use, or \
maybe it was still around from a crash? \
Official error: {err}."
).into());
}
};

surprise_stream_listener.set_nonblocking(ListenerNonblockingMode::Both)?;

let shared_surprise_info = Rc::new(RefCell::new(SharedSurpriseInfo {
Expand Down

0 comments on commit c9d9508

Please sign in to comment.