refactor: tail log error that is ignorable (#1244)

This commit is contained in:
Myriad-Dreamin 2025-02-02 13:59:55 +08:00 committed by GitHub
parent 74c68f5485
commit 36d07464c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 82 additions and 92 deletions

View file

@ -304,7 +304,7 @@ impl LockFileUpdate {
}
pub fn commit(self) {
let err = super::LockFile::update(&self.root, |l| {
super::LockFile::update(&self.root, |l| {
let root: EcoString = unix_slash(&self.root).into();
let root_hash = tinymist_std::hash::hash128(&root);
for update in self.updates {
@ -334,10 +334,8 @@ impl LockFileUpdate {
let data = serde_json::to_string(&mat).unwrap();
let path = cache_dir.join("path-material.json");
let result = tinymist_std::fs::paths::write_atomic(path, data);
if let Err(err) = result {
log::error!("ProjectCompiler: write material error: {err}");
}
tinymist_std::fs::paths::write_atomic(path, data)
.log_error("ProjectCompiler: write material error");
// todo: clean up old cache
}
@ -350,10 +348,8 @@ impl LockFileUpdate {
}
Ok(())
});
if let Err(err) = err {
log::error!("ProjectCompiler: lock file error: {err}");
}
})
.log_error("ProjectCompiler: lock file error");
}
}

View file

@ -12,7 +12,7 @@
use std::collections::HashMap;
use notify::{Config, RecommendedWatcher, RecursiveMode, Watcher};
use tinymist_std::ImmutPath;
use tinymist_std::{error::IgnoreLogging, ImmutPath};
use tinymist_world::vfs::notify::NotifyDeps;
use tokio::sync::mpsc;
use typst::diag::FileError;
@ -110,14 +110,11 @@ impl<F: FnMut(FilesystemEvent) + Send + Sync> NotifyActor<F> {
/// Create a new actor.
pub fn new(interrupted_by_events: F) -> Self {
let (undetermined_send, undetermined_recv) = mpsc::unbounded_channel();
let (watcher_sender, watcher_receiver) = mpsc::unbounded_channel();
let (watcher_tx, watcher_rx) = mpsc::unbounded_channel();
let watcher = log_notify_error(
RecommendedWatcher::new(
move |event| {
let res = watcher_sender.send(event);
if let Err(err) = res {
log::warn!("error to send event: {err}");
}
watcher_tx.send(event).log_error("failed to send fs notify");
},
Config::default(),
),
@ -136,7 +133,7 @@ impl<F: FnMut(FilesystemEvent) + Send + Sync> NotifyActor<F> {
undetermined_recv,
watched_entries: HashMap::new(),
watcher: watcher.map(|it| (it, watcher_receiver)),
watcher: watcher.map(|it| (it, watcher_rx)),
}
}