mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-13 07:41:11 +01:00
Add RuntimeError::from_handler utility
This commit is contained in:
parent
4e4a8e6853
commit
6f3abdeaea
1 changed files with 16 additions and 0 deletions
|
@ -102,6 +102,22 @@ pub enum RuntimeError {
|
|||
#[source]
|
||||
err: mpsc::error::TrySendError<Event>,
|
||||
},
|
||||
|
||||
/// Error received when a [`Handler`][crate::Handler] errors.
|
||||
///
|
||||
/// The error is completely opaque, having been flattened into a string at the error point.
|
||||
#[error("handler error while {ctx}: {err}")]
|
||||
#[diagnostic(code(watchexec::runtime::handler))]
|
||||
Handler { ctx: &'static str, err: String },
|
||||
}
|
||||
|
||||
impl RuntimeError {
|
||||
pub(crate) fn from_handler(ctx: &'static str, err: impl std::error::Error) -> Self {
|
||||
Self::Handler {
|
||||
ctx,
|
||||
err: err.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Errors occurring from reconfigs.
|
||||
|
|
Loading…
Reference in a new issue