Add error variants for external custom errors

This commit is contained in:
Félix Saparelli 2021-10-09 18:38:37 +13:00
parent 81bee9513d
commit 3dff065f4b
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
1 changed files with 16 additions and 0 deletions

View File

@ -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<dyn std::error::Error + Send + Sync>),
/// 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<dyn std::error::Error + Send + Sync>),
/// Generic I/O error, with no additional context.
#[error(transparent)]
#[diagnostic(code(watchexec::runtime::io_error))]