use miette::Diagnostic;
use thiserror::Error;
use tokio::{sync::mpsc, task::JoinError};
use watchexec_events::{Event, Priority};
use super::{FsWatcherError, RuntimeError};
use crate::sources::fs::Watcher;
#[derive(Debug, Diagnostic, Error)]
#[non_exhaustive]
pub enum CriticalError {
#[error("this should never be printed (exit)")]
Exit,
#[error("external(critical): {0}")]
External(#[from] Box<dyn std::error::Error + Send + Sync>),
#[error("a runtime error is too serious for the process to continue")]
Elevated {
#[source]
err: RuntimeError,
help: Option<String>,
},
#[error("io({about}): {err}")]
IoError {
about: &'static str,
#[source]
err: std::io::Error,
},
#[error("cannot send internal runtime error: {0}")]
ErrorChannelSend(#[from] mpsc::error::SendError<RuntimeError>),
#[error("cannot send event to internal channel: {0}")]
EventChannelSend(#[from] async_priority_channel::SendError<(Event, Priority)>),
#[error("main task join: {0}")]
MainTaskJoin(#[source] JoinError),
#[error("fs: cannot initialise {kind:?} watcher")]
FsWatcherInit {
kind: Watcher,
#[source]
err: FsWatcherError,
},
}