use miette::Diagnostic;
use thiserror::Error;
use watchexec_events::{Event, Priority};
use watchexec_signals::Signal;
use crate::sources::fs::Watcher;
#[derive(Debug, Diagnostic, Error)]
#[non_exhaustive]
pub enum RuntimeError {
#[error("this should never be printed (exit)")]
Exit,
#[error("external(runtime): {0}")]
External(#[from] Box<dyn std::error::Error + Send + Sync>),
#[error("io({about}): {err}")]
IoError {
about: &'static str,
#[source]
err: std::io::Error,
},
#[error("{kind:?} fs watcher error")]
FsWatcher {
kind: Watcher,
#[source]
err: super::FsWatcherError,
},
#[error("keyboard watcher error")]
KeyboardWatcher {
#[source]
err: super::KeyboardWatcherError,
},
#[error("internal: command supervisor: {0}")]
InternalSupervisor(String),
#[error("cannot send event from {ctx}: {err}")]
EventChannelSend {
ctx: &'static str,
#[source]
err: async_priority_channel::SendError<(Event, Priority)>,
},
#[error("cannot send event from {ctx}: {err}")]
EventChannelTrySend {
ctx: &'static str,
#[source]
err: async_priority_channel::TrySendError<(Event, Priority)>,
},
#[error("handler error while {ctx}: {err}")]
Handler {
ctx: &'static str,
err: String,
},
#[error("{0} handler returned while holding a lock alive")]
HandlerLockHeld(&'static str),
#[error("when operating on process: {0}")]
Process(#[source] std::io::Error),
#[error("process was dead on arrival")]
ProcessDeadOnArrival,
#[error("unsupported signal: {0:?}")]
UnsupportedSignal(Signal),
#[error("no commands to run")]
NoCommands,
#[error("empty shelled command")]
CommandShellEmptyCommand,
#[error("empty shell program")]
CommandShellEmptyShell,
#[error("{kind} filterer: {err}")]
Filterer {
kind: &'static str,
#[source]
err: Box<dyn std::error::Error + Send + Sync>,
},
}