From 63e1892dc1c631f30c5f1652ee3bb0e6cb4f9c75 Mon Sep 17 00:00:00 2001 From: zyy17 Date: Tue, 13 Aug 2024 19:22:48 +0800 Subject: [PATCH] refactor(plugin): add SetupPlugin and StartPlugin error (#4554) --- src/datanode/src/error.rs | 23 ++++++++++++++++++++--- src/frontend/src/error.rs | 19 ++++++++++++++++++- src/meta-srv/src/error.rs | 18 +++++++++++++++++- 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/datanode/src/error.rs b/src/datanode/src/error.rs index cd1265569e..d070c82fb1 100644 --- a/src/datanode/src/error.rs +++ b/src/datanode/src/error.rs @@ -395,6 +395,20 @@ pub enum Error { #[snafu(implicit)] location: Location, }, + + #[snafu(display("Failed to setup plugin"))] + SetupPlugin { + #[snafu(implicit)] + location: Location, + source: BoxedError, + }, + + #[snafu(display("Failed to start plugin"))] + StartPlugin { + #[snafu(implicit)] + location: Location, + source: BoxedError, + }, } pub type Result = std::result::Result; @@ -442,9 +456,12 @@ impl ErrorExt for Error { AsyncTaskExecute { source, .. } => source.status_code(), - CreateDir { .. } | RemoveDir { .. } | ShutdownInstance { .. } | DataFusion { .. } => { - StatusCode::Internal - } + CreateDir { .. } + | RemoveDir { .. } + | ShutdownInstance { .. } + | DataFusion { .. } + | SetupPlugin { .. } + | StartPlugin { .. } => StatusCode::Internal, RegionNotFound { .. } => StatusCode::RegionNotFound, RegionNotReady { .. } => StatusCode::RegionNotReady, diff --git a/src/frontend/src/error.rs b/src/frontend/src/error.rs index c925b2ea1a..cb0df405c5 100644 --- a/src/frontend/src/error.rs +++ b/src/frontend/src/error.rs @@ -364,6 +364,20 @@ pub enum Error { #[snafu(implicit)] location: Location, }, + + #[snafu(display("Failed to setup plugin"))] + SetupPlugin { + #[snafu(implicit)] + location: Location, + source: BoxedError, + }, + + #[snafu(display("Failed to start plugin"))] + StartPlugin { + #[snafu(implicit)] + location: Location, + source: BoxedError, + }, } pub type Result = std::result::Result; @@ -416,7 +430,10 @@ impl ErrorExt for Error { Error::FindDatanode { .. } => StatusCode::RegionNotReady, - Error::VectorToGrpcColumn { .. } | Error::CacheRequired { .. } => StatusCode::Internal, + Error::VectorToGrpcColumn { .. } + | Error::CacheRequired { .. } + | Error::SetupPlugin { .. } + | Error::StartPlugin { .. } => StatusCode::Internal, Error::InvalidRegionRequest { .. } => StatusCode::IllegalState, diff --git a/src/meta-srv/src/error.rs b/src/meta-srv/src/error.rs index 6e9efc4857..8c5312fe91 100644 --- a/src/meta-srv/src/error.rs +++ b/src/meta-srv/src/error.rs @@ -851,6 +851,20 @@ pub enum Error { #[snafu(source(from(common_config::error::Error, Box::new)))] source: Box, }, + + #[snafu(display("Failed to setup plugin"))] + SetupPlugin { + #[snafu(implicit)] + location: Location, + source: BoxedError, + }, + + #[snafu(display("Failed to start plugin"))] + StartPlugin { + #[snafu(implicit)] + location: Location, + source: BoxedError, + }, } impl Error { @@ -902,7 +916,9 @@ impl ErrorExt for Error { | Error::Join { .. } | Error::WeightArray { .. } | Error::NotSetWeightArray { .. } - | Error::PeerUnavailable { .. } => StatusCode::Internal, + | Error::PeerUnavailable { .. } + | Error::SetupPlugin { .. } + | Error::StartPlugin { .. } => StatusCode::Internal, Error::Unsupported { .. } => StatusCode::Unsupported,