1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

pub mod args;
pub mod local;
pub mod tasktrack;
pub mod sequence;
pub mod ksmode;
pub mod ledpins;
pub mod debounce;
pub mod config;

use thiserror::Error;

#[derive(Error,Debug)]
#[error("RecvError - watch::Receiver.recv() gave None")]
pub struct RecvError{}

#[macro_export]
macro_rules! wrap_main {
  ( $what:expr ) => {
    #[tokio::main]
    async fn main() {
      let old_hook = std::panic::take_hook();
      std::panic::set_hook(Box::new(move |i| {
        eprintln!("{}: panicing!", $what);
        old_hook(i);
        eprintln!("{}: paniced!", $what);
        std::process::exit(16);
      }));
      if let Err(e) = real_main().await {
        eprintln!("{}: crashing: {:?}", $what, e);
        std::process::exit(12);
      }
    }
  }
}