watchexec/crates/lib/tests/error_handler.rs

23 lines
417 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::{ErrorHook, Watchexec};
#[tokio::main]
2021-10-10 10:04:40 +02:00
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
let wx = Watchexec::default();
wx.config.on_error(|err: ErrorHook| {
eprintln!("Watchexec Runtime Error: {}", err.error);
});
wx.main();
// TODO: induce an error here
sleep(Duration::from_secs(1)).await;
Ok(())
}