watchexec/crates/lib/tests/error_handler.rs

31 lines
598 B
Rust
Raw Normal View History

use std::time::Duration;
2021-10-10 10:04:40 +02:00
use miette::Result;
use tokio::time::sleep;
use watchexec::{
config::{InitConfig, RuntimeConfig},
ErrorHook, Watchexec,
};
#[tokio::main]
2021-10-10 10:04:40 +02:00
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
let mut init = InitConfig::default();
init.on_error(|err: ErrorHook| async move {
eprintln!("Watchexec Runtime Error: {}", err.error);
Ok::<(), std::convert::Infallible>(())
});
2021-08-22 10:49:24 +02:00
let runtime = RuntimeConfig::default();
let wx = Watchexec::new(init, runtime)?;
wx.main();
// TODO: induce an error here
sleep(Duration::from_secs(1)).await;
Ok(())
}