Use eyre, dont crash on watch error
This commit is contained in:
parent
e9023eec02
commit
ddd748015a
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"rust-analyzer.checkOnSave.extraArgs": [
|
||||
"--target-dir",
|
||||
"target/check"
|
||||
],
|
||||
}
|
|
@ -164,6 +164,16 @@ dependencies = [
|
|||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "eyre"
|
||||
version = "0.6.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec"
|
||||
dependencies = [
|
||||
"indenter",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.0.1"
|
||||
|
@ -297,6 +307,7 @@ dependencies = [
|
|||
"notify",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"stable-eyre",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -411,6 +422,12 @@ dependencies = [
|
|||
"unicode-normalization",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indenter"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.1.0"
|
||||
|
@ -914,6 +931,17 @@ dependencies = [
|
|||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stable-eyre"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "556fec8c2da34c70b75f16d88df8a8cd7e652e567ff097b7e9df0022c8695cc4"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"eyre",
|
||||
"indenter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.41"
|
||||
|
|
|
@ -11,3 +11,4 @@ figment = { version = "0.10.12", features = ["env"] }
|
|||
notify = "6.1.1"
|
||||
reqwest = { version = "0.11.22", features = ["blocking"] }
|
||||
serde = { version = "1.0.193", features = ["serde_derive"] }
|
||||
stable-eyre = "0.2.2"
|
||||
|
|
15
src/main.rs
15
src/main.rs
|
@ -5,6 +5,7 @@ use figment::{Figment, providers::Env};
|
|||
use notify::{RecursiveMode, Watcher, Event, EventKind, event::{ModifyKind, DataChange}};
|
||||
use reqwest::StatusCode;
|
||||
use serde::Deserialize;
|
||||
use stable_eyre::eyre::Report;
|
||||
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
struct Config {
|
||||
|
@ -30,7 +31,9 @@ impl Config {
|
|||
}
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
fn main() -> Result<(), Report> {
|
||||
stable_eyre::install()?;
|
||||
|
||||
let config: Arc<Config> = Arc::new(Figment::new()
|
||||
.merge(Env::prefixed("PORT_UPD_"))
|
||||
.extract()?);
|
||||
|
@ -76,7 +79,15 @@ fn main() -> anyhow::Result<()> {
|
|||
}
|
||||
|
||||
loop {
|
||||
watcher.watch(port_path, RecursiveMode::Recursive)?;
|
||||
match watcher.watch(port_path, RecursiveMode::Recursive) {
|
||||
Ok(()) => {},
|
||||
Err(e) => {
|
||||
println!("watch error: {:?}", e);
|
||||
|
||||
println!("Trying again in 10 seconds");
|
||||
std::thread::sleep(Duration::from_secs(10));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue