From 3dff065f4bb87b4770f57a5c188ccff4e22964a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Sat, 9 Oct 2021 18:38:37 +1300 Subject: [PATCH] Add error variants for external custom errors --- lib/src/error.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/src/error.rs b/lib/src/error.rs index e58f178d..a7bd74b9 100644 --- a/lib/src/error.rs +++ b/lib/src/error.rs @@ -25,6 +25,14 @@ pub enum CriticalError { #[diagnostic(code(watchexec::runtime::exit))] Exit, + /// For custom critical errors. + /// + /// This should be used for errors by external code which are not covered by the other error + /// types; watchexec-internal errors should never use this. + #[error("external(critical): {0}")] + #[diagnostic(code(watchexec::critical::external))] + External(#[from] Box), + /// A critical I/O error occurred. #[error(transparent)] #[diagnostic(code(watchexec::critical::io_error))] @@ -63,6 +71,14 @@ pub enum RuntimeError { #[diagnostic(code(watchexec::runtime::exit))] Exit, + /// For custom runtime errors. + /// + /// This should be used for errors by external code which are not covered by the other error + /// types; watchexec-internal errors should never use this. + #[error("external(runtime): {0}")] + #[diagnostic(code(watchexec::runtime::external))] + External(#[from] Box), + /// Generic I/O error, with no additional context. #[error(transparent)] #[diagnostic(code(watchexec::runtime::io_error))]