Skip to content

Commit

Permalink
refactor(plugin): add SetupPlugin and StartPlugin error (#4554)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyy17 authored Aug 13, 2024
1 parent 216bce6 commit 63e1892
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
23 changes: 20 additions & 3 deletions src/datanode/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = std::result::Result<T, Error>;
Expand Down Expand Up @@ -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,
Expand Down
19 changes: 18 additions & 1 deletion src/frontend/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = std::result::Result<T, Error>;
Expand Down Expand Up @@ -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,

Expand Down
18 changes: 17 additions & 1 deletion src/meta-srv/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,20 @@ pub enum Error {
#[snafu(source(from(common_config::error::Error, Box::new)))]
source: Box<common_config::error::Error>,
},

#[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 {
Expand Down Expand Up @@ -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,

Expand Down

0 comments on commit 63e1892

Please sign in to comment.