summaryrefslogtreecommitdiff
path: root/cli/file_watcher.rs
diff options
context:
space:
mode:
authorBert Belder <bertbelder@gmail.com>2020-09-14 18:48:57 +0200
committerBert Belder <bertbelder@gmail.com>2020-09-15 01:50:52 +0200
commitf5b40c918c7d602827622d167728a3e7bae87d9d (patch)
treefb51722e043f4d6bce64a2c7e897cce4ead06c82 /cli/file_watcher.rs
parent3da20d19a14ab6838897d281f1b11e49d68bd1a7 (diff)
refactor: use the 'anyhow' crate instead of 'ErrBox' (#7476)
Diffstat (limited to 'cli/file_watcher.rs')
-rw-r--r--cli/file_watcher.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/cli/file_watcher.rs b/cli/file_watcher.rs
index 892d0d4a1..b9c18c17f 100644
--- a/cli/file_watcher.rs
+++ b/cli/file_watcher.rs
@@ -1,5 +1,5 @@
use crate::colors;
-use deno_core::ErrBox;
+use deno_core::error::AnyError;
use futures::stream::StreamExt;
use futures::Future;
use notify::event::Event as NotifyEvent;
@@ -15,8 +15,7 @@ use tokio::select;
use tokio::sync::mpsc;
// TODO(bartlomieju): rename
-type WatchFuture =
- Pin<Box<dyn Future<Output = std::result::Result<(), deno_core::ErrBox>>>>;
+type WatchFuture = Pin<Box<dyn Future<Output = Result<(), AnyError>>>>;
async fn error_handler(watch_future: WatchFuture) {
let result = watch_future.await;
@@ -29,7 +28,7 @@ async fn error_handler(watch_future: WatchFuture) {
pub async fn watch_func<F>(
watch_paths: &[PathBuf],
closure: F,
-) -> Result<(), ErrBox>
+) -> Result<(), AnyError>
where
F: Fn() -> WatchFuture,
{
@@ -60,13 +59,14 @@ where
}
}
-pub async fn file_watcher(paths: &[PathBuf]) -> Result<(), deno_core::ErrBox> {
- let (sender, mut receiver) = mpsc::channel::<Result<NotifyEvent, ErrBox>>(16);
+pub async fn file_watcher(paths: &[PathBuf]) -> Result<(), AnyError> {
+ let (sender, mut receiver) =
+ mpsc::channel::<Result<NotifyEvent, AnyError>>(16);
let sender = std::sync::Mutex::new(sender);
let mut watcher: RecommendedWatcher =
Watcher::new_immediate(move |res: Result<NotifyEvent, NotifyError>| {
- let res2 = res.map_err(ErrBox::from);
+ let res2 = res.map_err(AnyError::from);
let mut sender = sender.lock().unwrap();
// Ignore result, if send failed it means that watcher was already closed,
// but not all messages have been flushed.