mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-03 11:52:54 +00:00
feat: tweak error and status codes (#4359)
* feat: tweak status codes * fix: typo * fix: by cr comments
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::{Location, Snafu};
|
||||
@@ -38,13 +38,6 @@ pub enum Error {
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Auth failed"))]
|
||||
AuthBackend {
|
||||
#[snafu(implicit)]
|
||||
location: Location,
|
||||
source: BoxedError,
|
||||
},
|
||||
|
||||
#[snafu(display("User not found, username: {}", username))]
|
||||
UserNotFound { username: String },
|
||||
|
||||
@@ -87,8 +80,7 @@ impl ErrorExt for Error {
|
||||
Error::IllegalParam { .. } => StatusCode::InvalidArguments,
|
||||
Error::FileWatch { .. } => StatusCode::InvalidArguments,
|
||||
Error::InternalState { .. } => StatusCode::Unexpected,
|
||||
Error::Io { .. } => StatusCode::Internal,
|
||||
Error::AuthBackend { .. } => StatusCode::Internal,
|
||||
Error::Io { .. } => StatusCode::StorageUnavailable,
|
||||
|
||||
Error::UserNotFound { .. } => StatusCode::UserNotFound,
|
||||
Error::UnsupportedPasswordType { .. } => StatusCode::UnsupportedPasswordType,
|
||||
|
||||
2
src/cache/src/error.rs
vendored
2
src/cache/src/error.rs
vendored
@@ -34,7 +34,7 @@ pub type Result<T> = std::result::Result<T, Error>;
|
||||
impl ErrorExt for Error {
|
||||
fn status_code(&self) -> StatusCode {
|
||||
match self {
|
||||
Error::CacheRequired { .. } => StatusCode::Internal,
|
||||
Error::CacheRequired { .. } => StatusCode::Unexpected,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,13 +53,6 @@ pub enum Error {
|
||||
source: common_grpc::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Column datatype error"))]
|
||||
ColumnDataType {
|
||||
#[snafu(implicit)]
|
||||
location: Location,
|
||||
source: api::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Illegal GRPC client state: {}", err_msg))]
|
||||
IllegalGrpcClientState {
|
||||
err_msg: String,
|
||||
@@ -137,7 +130,6 @@ impl ErrorExt for Error {
|
||||
fn status_code(&self) -> StatusCode {
|
||||
match self {
|
||||
Error::IllegalFlightMessages { .. }
|
||||
| Error::ColumnDataType { .. }
|
||||
| Error::MissingField { .. }
|
||||
| Error::IllegalDatabaseResponse { .. }
|
||||
| Error::ClientStreaming { .. } => StatusCode::Internal,
|
||||
|
||||
@@ -54,8 +54,8 @@ pub enum Error {
|
||||
impl ErrorExt for Error {
|
||||
fn status_code(&self) -> StatusCode {
|
||||
match self {
|
||||
Error::BigDecimalOutOfRange { .. } => StatusCode::Internal,
|
||||
Error::ParseRustDecimalStr { .. }
|
||||
Error::BigDecimalOutOfRange { .. }
|
||||
| Error::ParseRustDecimalStr { .. }
|
||||
| Error::InvalidPrecisionOrScale { .. }
|
||||
| Error::ParseBigDecimalStr { .. } => StatusCode::InvalidArguments,
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ pub enum StatusCode {
|
||||
InvalidArguments = 1004,
|
||||
/// The task is cancelled.
|
||||
Cancelled = 1005,
|
||||
/// Illegal state, can be exposed to users
|
||||
IllegalState = 1006,
|
||||
// ====== End of common status code ================
|
||||
|
||||
// ====== Begin of SQL related status code =========
|
||||
@@ -53,18 +55,27 @@ pub enum StatusCode {
|
||||
// ====== Begin of catalog related status code =====
|
||||
/// Table already exists.
|
||||
TableAlreadyExists = 4000,
|
||||
/// Table not found
|
||||
TableNotFound = 4001,
|
||||
/// Table column not found
|
||||
TableColumnNotFound = 4002,
|
||||
/// Table column already exists
|
||||
TableColumnExists = 4003,
|
||||
/// Database not found
|
||||
DatabaseNotFound = 4004,
|
||||
/// Region not found
|
||||
RegionNotFound = 4005,
|
||||
/// Region already exists
|
||||
RegionAlreadyExists = 4006,
|
||||
RegionReadonly = 4007,
|
||||
/// Region is not in a proper state to handle specific request.
|
||||
RegionNotReady = 4008,
|
||||
// If mutually exclusive operations are reached at the same time,
|
||||
// only one can be executed, another one will get region busy.
|
||||
/// Region is temporarily in busy state
|
||||
RegionBusy = 4009,
|
||||
/// Table is temporarily unable to handle the request
|
||||
TableUnavailable = 4010,
|
||||
/// Database not found
|
||||
DatabaseAlreadyExists = 4011,
|
||||
// ====== End of catalog related status code =======
|
||||
|
||||
// ====== Begin of storage related status code =====
|
||||
@@ -118,15 +129,18 @@ impl StatusCode {
|
||||
| StatusCode::RuntimeResourcesExhausted
|
||||
| StatusCode::Internal
|
||||
| StatusCode::RegionNotReady
|
||||
| StatusCode::TableUnavailable
|
||||
| StatusCode::RegionBusy => true,
|
||||
|
||||
StatusCode::Success
|
||||
| StatusCode::Unknown
|
||||
| StatusCode::Unsupported
|
||||
| StatusCode::IllegalState
|
||||
| StatusCode::Unexpected
|
||||
| StatusCode::InvalidArguments
|
||||
| StatusCode::Cancelled
|
||||
| StatusCode::InvalidSyntax
|
||||
| StatusCode::DatabaseAlreadyExists
|
||||
| StatusCode::PlanQuery
|
||||
| StatusCode::EngineExecuteQuery
|
||||
| StatusCode::TableAlreadyExists
|
||||
@@ -159,6 +173,7 @@ impl StatusCode {
|
||||
| StatusCode::Unexpected
|
||||
| StatusCode::Internal
|
||||
| StatusCode::Cancelled
|
||||
| StatusCode::IllegalState
|
||||
| StatusCode::EngineExecuteQuery
|
||||
| StatusCode::StorageUnavailable
|
||||
| StatusCode::RuntimeResourcesExhausted => true,
|
||||
@@ -181,6 +196,8 @@ impl StatusCode {
|
||||
| StatusCode::DatabaseNotFound
|
||||
| StatusCode::RateLimited
|
||||
| StatusCode::UserNotFound
|
||||
| StatusCode::TableUnavailable
|
||||
| StatusCode::DatabaseAlreadyExists
|
||||
| StatusCode::UnsupportedPasswordType
|
||||
| StatusCode::UserPasswordMismatch
|
||||
| StatusCode::AuthHeaderNotFound
|
||||
@@ -241,6 +258,7 @@ pub fn status_to_tonic_code(status_code: StatusCode) -> Code {
|
||||
StatusCode::Unknown => Code::Unknown,
|
||||
StatusCode::Unsupported => Code::Unimplemented,
|
||||
StatusCode::Unexpected
|
||||
| StatusCode::IllegalState
|
||||
| StatusCode::Internal
|
||||
| StatusCode::PlanQuery
|
||||
| StatusCode::EngineExecuteQuery => Code::Internal,
|
||||
@@ -251,6 +269,7 @@ pub fn status_to_tonic_code(status_code: StatusCode) -> Code {
|
||||
StatusCode::TableAlreadyExists
|
||||
| StatusCode::TableColumnExists
|
||||
| StatusCode::RegionAlreadyExists
|
||||
| StatusCode::DatabaseAlreadyExists
|
||||
| StatusCode::FlowAlreadyExists => Code::AlreadyExists,
|
||||
StatusCode::TableNotFound
|
||||
| StatusCode::RegionNotFound
|
||||
@@ -258,7 +277,9 @@ pub fn status_to_tonic_code(status_code: StatusCode) -> Code {
|
||||
| StatusCode::DatabaseNotFound
|
||||
| StatusCode::UserNotFound
|
||||
| StatusCode::FlowNotFound => Code::NotFound,
|
||||
StatusCode::StorageUnavailable | StatusCode::RegionNotReady => Code::Unavailable,
|
||||
StatusCode::TableUnavailable
|
||||
| StatusCode::StorageUnavailable
|
||||
| StatusCode::RegionNotReady => Code::Unavailable,
|
||||
StatusCode::RuntimeResourcesExhausted
|
||||
| StatusCode::RateLimited
|
||||
| StatusCode::RegionBusy => Code::ResourceExhausted,
|
||||
|
||||
@@ -658,9 +658,12 @@ impl ErrorExt for Error {
|
||||
| EtcdTxnFailed { .. }
|
||||
| ConnectEtcd { .. }
|
||||
| MoveValues { .. }
|
||||
| ValueNotExist { .. }
|
||||
| GetCache { .. } => StatusCode::Internal,
|
||||
|
||||
ValueNotExist { .. } => StatusCode::Unexpected,
|
||||
|
||||
Unsupported { .. } => StatusCode::Unsupported,
|
||||
|
||||
SerdeJson { .. }
|
||||
| ParseOption { .. }
|
||||
| RouteInfoCorrupted { .. }
|
||||
@@ -696,17 +699,16 @@ impl ErrorExt for Error {
|
||||
| FromUtf8 { .. }
|
||||
| MetadataCorruption { .. } => StatusCode::Unexpected,
|
||||
|
||||
SendMessage { .. }
|
||||
| GetKvCache { .. }
|
||||
| CacheNotGet { .. }
|
||||
| CatalogAlreadyExists { .. }
|
||||
| SchemaAlreadyExists { .. }
|
||||
| RenameTable { .. }
|
||||
| Unsupported { .. } => StatusCode::Internal,
|
||||
SendMessage { .. } | GetKvCache { .. } | CacheNotGet { .. } | RenameTable { .. } => {
|
||||
StatusCode::Internal
|
||||
}
|
||||
|
||||
SchemaAlreadyExists { .. } => StatusCode::DatabaseAlreadyExists,
|
||||
|
||||
ProcedureNotFound { .. }
|
||||
| InvalidViewInfo { .. }
|
||||
| PrimaryKeyNotFound { .. }
|
||||
| CatalogAlreadyExists { .. }
|
||||
| EmptyKey { .. }
|
||||
| InvalidEngineType { .. }
|
||||
| AlterLogicalTablesInvalidArguments { .. }
|
||||
|
||||
@@ -205,13 +205,15 @@ impl ErrorExt for Error {
|
||||
Error::ToJson { .. }
|
||||
| Error::DeleteState { .. }
|
||||
| Error::FromJson { .. }
|
||||
| Error::RetryTimesExceeded { .. }
|
||||
| Error::RollbackTimesExceeded { .. }
|
||||
| Error::RetryLater { .. }
|
||||
| Error::WaitWatcher { .. }
|
||||
| Error::ManagerNotStart { .. }
|
||||
| Error::RollbackProcedureRecovered { .. }
|
||||
| Error::RollbackNotSupported { .. } => StatusCode::Internal,
|
||||
| Error::RetryLater { .. }
|
||||
| Error::RollbackProcedureRecovered { .. } => StatusCode::Internal,
|
||||
|
||||
Error::RetryTimesExceeded { .. }
|
||||
| Error::RollbackTimesExceeded { .. }
|
||||
| Error::ManagerNotStart { .. } => StatusCode::IllegalState,
|
||||
|
||||
Error::RollbackNotSupported { .. } => StatusCode::Unsupported,
|
||||
Error::LoaderConflict { .. } | Error::DuplicateProcedure { .. } => {
|
||||
StatusCode::InvalidArguments
|
||||
}
|
||||
|
||||
@@ -167,9 +167,11 @@ impl ErrorExt for Error {
|
||||
| Error::PollStream { .. }
|
||||
| Error::Format { .. }
|
||||
| Error::ToArrowScalar { .. }
|
||||
| Error::ColumnNotExists { .. }
|
||||
| Error::ProjectArrowRecordBatch { .. }
|
||||
| Error::ArrowCompute { .. } => StatusCode::Internal,
|
||||
| Error::ProjectArrowRecordBatch { .. } => StatusCode::Internal,
|
||||
|
||||
Error::ArrowCompute { .. } => StatusCode::IllegalState,
|
||||
|
||||
Error::ColumnNotExists { .. } => StatusCode::TableColumnNotFound,
|
||||
|
||||
Error::External { source, .. } => source.status_code(),
|
||||
|
||||
|
||||
@@ -87,10 +87,8 @@ impl ErrorExt for Error {
|
||||
Error::UnknownPlan { .. } | Error::EncodeRel { .. } | Error::DecodeRel { .. } => {
|
||||
StatusCode::InvalidArguments
|
||||
}
|
||||
Error::DFInternal { .. }
|
||||
| Error::Internal { .. }
|
||||
| Error::EncodeDfPlan { .. }
|
||||
| Error::DecodeDfPlan { .. } => StatusCode::Internal,
|
||||
Error::DFInternal { .. } | Error::Internal { .. } => StatusCode::Internal,
|
||||
Error::EncodeDfPlan { .. } | Error::DecodeDfPlan { .. } => StatusCode::Unexpected,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,13 +78,6 @@ pub enum Error {
|
||||
source: common_query::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Incorrect internal state: {}", state))]
|
||||
IncorrectInternalState {
|
||||
state: String,
|
||||
#[snafu(implicit)]
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Catalog not found: {}", name))]
|
||||
CatalogNotFound {
|
||||
name: String,
|
||||
@@ -436,6 +429,10 @@ impl ErrorExt for Error {
|
||||
| MissingNodeId { .. }
|
||||
| ColumnNoneDefaultValue { .. }
|
||||
| MissingWalDirConfig { .. }
|
||||
| Catalog { .. }
|
||||
| MissingRequiredField { .. }
|
||||
| RegionEngineNotFound { .. }
|
||||
| ParseAddr { .. }
|
||||
| MissingKvBackend { .. }
|
||||
| TomlFormat { .. } => StatusCode::InvalidArguments,
|
||||
|
||||
@@ -445,17 +442,9 @@ impl ErrorExt for Error {
|
||||
|
||||
AsyncTaskExecute { source, .. } => source.status_code(),
|
||||
|
||||
// TODO(yingwen): Further categorize http error.
|
||||
ParseAddr { .. }
|
||||
| CreateDir { .. }
|
||||
| RemoveDir { .. }
|
||||
| Catalog { .. }
|
||||
| MissingRequiredField { .. }
|
||||
| IncorrectInternalState { .. }
|
||||
| ShutdownInstance { .. }
|
||||
| RegionEngineNotFound { .. }
|
||||
| UnsupportedOutput { .. }
|
||||
| DataFusion { .. } => StatusCode::Internal,
|
||||
CreateDir { .. } | RemoveDir { .. } | ShutdownInstance { .. } | DataFusion { .. } => {
|
||||
StatusCode::Internal
|
||||
}
|
||||
|
||||
RegionNotFound { .. } => StatusCode::RegionNotFound,
|
||||
RegionNotReady { .. } => StatusCode::RegionNotReady,
|
||||
@@ -468,9 +457,9 @@ impl ErrorExt for Error {
|
||||
OpenLogStore { source, .. } => source.status_code(),
|
||||
RuntimeResource { .. } => StatusCode::RuntimeResourcesExhausted,
|
||||
MetaClientInit { source, .. } => source.status_code(),
|
||||
TableIdProviderNotFound { .. } | UnsupportedGrpcRequest { .. } => {
|
||||
StatusCode::Unsupported
|
||||
}
|
||||
UnsupportedOutput { .. }
|
||||
| TableIdProviderNotFound { .. }
|
||||
| UnsupportedGrpcRequest { .. } => StatusCode::Unsupported,
|
||||
HandleRegionRequest { source, .. }
|
||||
| GetRegionMetadata { source, .. }
|
||||
| HandleBatchOpenRequest { source, .. } => source.status_code(),
|
||||
|
||||
@@ -209,8 +209,36 @@ pub enum Error {
|
||||
|
||||
impl ErrorExt for Error {
|
||||
fn status_code(&self) -> StatusCode {
|
||||
// Inner encoding and decoding error should not be exposed to users.
|
||||
StatusCode::Internal
|
||||
use Error::*;
|
||||
match self {
|
||||
UnsupportedOperation { .. }
|
||||
| UnsupportedArrowType { .. }
|
||||
| UnsupportedDefaultExpr { .. } => StatusCode::Unsupported,
|
||||
|
||||
DuplicateColumn { .. }
|
||||
| BadArrayAccess { .. }
|
||||
| NullDefault { .. }
|
||||
| InvalidTimestampIndex { .. }
|
||||
| DefaultValueType { .. }
|
||||
| DuplicateMeta { .. }
|
||||
| InvalidTimestampPrecision { .. }
|
||||
| InvalidPrecisionOrScale { .. } => StatusCode::InvalidArguments,
|
||||
|
||||
ValueExceedsPrecision { .. }
|
||||
| CastType { .. }
|
||||
| CastTimeType { .. }
|
||||
| Conversion { .. } => StatusCode::IllegalState,
|
||||
|
||||
Serialize { .. }
|
||||
| Deserialize { .. }
|
||||
| UnknownVector { .. }
|
||||
| ParseSchemaVersion { .. }
|
||||
| ArrowCompute { .. }
|
||||
| ProjectArrowSchema { .. }
|
||||
| ToScalarValue { .. }
|
||||
| TryFromValue { .. }
|
||||
| ConvertArrowArrayToScalars { .. } => StatusCode::Internal,
|
||||
}
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
|
||||
@@ -413,10 +413,11 @@ impl ErrorExt for Error {
|
||||
|
||||
Error::RequestQuery { source, .. } => source.status_code(),
|
||||
|
||||
Error::FindDatanode { .. }
|
||||
| Error::VectorToGrpcColumn { .. }
|
||||
| Error::InvalidRegionRequest { .. }
|
||||
| Error::CacheRequired { .. } => StatusCode::Internal,
|
||||
Error::FindDatanode { .. } => StatusCode::RegionNotReady,
|
||||
|
||||
Error::VectorToGrpcColumn { .. } | Error::CacheRequired { .. } => StatusCode::Internal,
|
||||
|
||||
Error::InvalidRegionRequest { .. } => StatusCode::IllegalState,
|
||||
|
||||
Error::ContextValueNotFound { .. } => StatusCode::Unexpected,
|
||||
|
||||
|
||||
@@ -888,7 +888,6 @@ impl ErrorExt for Error {
|
||||
| Error::LockNotConfig { .. }
|
||||
| Error::ExceededRetryLimit { .. }
|
||||
| Error::SendShutdownSignal { .. }
|
||||
| Error::SchemaAlreadyExists { .. }
|
||||
| Error::PusherNotFound { .. }
|
||||
| Error::PushMessage { .. }
|
||||
| Error::MailboxClosed { .. }
|
||||
@@ -903,8 +902,12 @@ impl ErrorExt for Error {
|
||||
| Error::Join { .. }
|
||||
| Error::WeightArray { .. }
|
||||
| Error::NotSetWeightArray { .. }
|
||||
| Error::Unsupported { .. }
|
||||
| Error::PeerUnavailable { .. } => StatusCode::Internal,
|
||||
|
||||
Error::Unsupported { .. } => StatusCode::Unsupported,
|
||||
|
||||
Error::SchemaAlreadyExists { .. } => StatusCode::DatabaseAlreadyExists,
|
||||
|
||||
Error::TableAlreadyExists { .. } => StatusCode::TableAlreadyExists,
|
||||
Error::EmptyKey { .. }
|
||||
| Error::MissingRequiredParameter { .. }
|
||||
|
||||
@@ -882,26 +882,32 @@ impl ErrorExt for Error {
|
||||
| WorkerStopped { .. }
|
||||
| Recv { .. }
|
||||
| EncodeWal { .. }
|
||||
| ConvertMetaData { .. }
|
||||
| DecodeWal { .. }
|
||||
| ComputeArrow { .. }
|
||||
| BiError { .. }
|
||||
| StopScheduler { .. }
|
||||
| ComputeVector { .. }
|
||||
| SerializeField { .. }
|
||||
| EncodeMemtable { .. }
|
||||
| ReadDataPart { .. }
|
||||
| CorruptedEntry { .. }
|
||||
| BuildEntry { .. } => StatusCode::Internal,
|
||||
|
||||
OpenRegion { source, .. } => source.status_code(),
|
||||
|
||||
WriteParquet { .. } => StatusCode::Internal,
|
||||
WriteParquet { .. } => StatusCode::StorageUnavailable,
|
||||
WriteGroup { source, .. } => source.status_code(),
|
||||
FieldTypeMismatch { source, .. } => source.status_code(),
|
||||
SerializeField { .. } => StatusCode::Internal,
|
||||
NotSupportedField { .. } => StatusCode::Unsupported,
|
||||
DeserializeField { .. } => StatusCode::Unexpected,
|
||||
InvalidBatch { .. } => StatusCode::InvalidArguments,
|
||||
InvalidRecordBatch { .. } => StatusCode::InvalidArguments,
|
||||
ConvertVector { source, .. } => source.status_code(),
|
||||
ConvertMetaData { .. } => StatusCode::Internal,
|
||||
ComputeArrow { .. } => StatusCode::Internal,
|
||||
ComputeVector { .. } => StatusCode::Internal,
|
||||
|
||||
PrimaryKeyLengthMismatch { .. } => StatusCode::InvalidArguments,
|
||||
InvalidSender { .. } => StatusCode::InvalidArguments,
|
||||
InvalidSchedulerState { .. } => StatusCode::InvalidArguments,
|
||||
StopScheduler { .. } => StatusCode::Internal,
|
||||
DeleteSst { .. } | DeleteIndex { .. } => StatusCode::StorageUnavailable,
|
||||
FlushRegion { source, .. } => source.status_code(),
|
||||
RegionDropped { .. } => StatusCode::Cancelled,
|
||||
@@ -932,10 +938,6 @@ impl ErrorExt for Error {
|
||||
FilterRecordBatch { source, .. } => source.status_code(),
|
||||
|
||||
Upload { .. } => StatusCode::StorageUnavailable,
|
||||
BiError { .. } => StatusCode::Internal,
|
||||
EncodeMemtable { .. } | ReadDataPart { .. } | CorruptedEntry { .. } => {
|
||||
StatusCode::Internal
|
||||
}
|
||||
ChecksumMismatch { .. } => StatusCode::Unexpected,
|
||||
RegionStopped { .. } => StatusCode::RegionNotReady,
|
||||
TimeRangePredicateOverflow { .. } => StatusCode::InvalidArguments,
|
||||
|
||||
@@ -205,25 +205,31 @@ impl ErrorExt for Error {
|
||||
fn status_code(&self) -> StatusCode {
|
||||
match self {
|
||||
Error::GetCache { .. } | Error::FindLeader { .. } => StatusCode::StorageUnavailable,
|
||||
Error::FindRegionRoutes { .. }
|
||||
| Error::ConjunctExprWithNonExpr { .. }
|
||||
Error::FindRegionRoutes { .. } => StatusCode::RegionNotReady,
|
||||
|
||||
Error::ConjunctExprWithNonExpr { .. }
|
||||
| Error::UnclosedValue { .. }
|
||||
| Error::InvalidExpr { .. }
|
||||
| Error::FindTableRoutes { .. }
|
||||
| Error::UndefinedColumn { .. } => StatusCode::InvalidArguments,
|
||||
|
||||
Error::FindRegion { .. }
|
||||
| Error::FindRegions { .. }
|
||||
| Error::RegionKeysSize { .. }
|
||||
| Error::InvalidInsertRequest { .. }
|
||||
| Error::InvalidDeleteRequest { .. } => StatusCode::InvalidArguments,
|
||||
Error::SerializeJson { .. } | Error::DeserializeJson { .. } => StatusCode::Internal,
|
||||
|
||||
Error::ConvertScalarValue { .. }
|
||||
| Error::SerializeJson { .. }
|
||||
| Error::DeserializeJson { .. } => StatusCode::Internal,
|
||||
|
||||
Error::Unexpected { .. } => StatusCode::Unexpected,
|
||||
Error::InvalidTableRouteData { .. } => StatusCode::Internal,
|
||||
Error::ConvertScalarValue { .. } => StatusCode::Internal,
|
||||
Error::FindDatanode { .. } => StatusCode::InvalidArguments,
|
||||
Error::InvalidTableRouteData { .. } => StatusCode::TableUnavailable,
|
||||
Error::FindTableRoutes { .. } | Error::FindDatanode { .. } => {
|
||||
StatusCode::TableUnavailable
|
||||
}
|
||||
Error::TableRouteNotFound { .. } => StatusCode::TableNotFound,
|
||||
Error::TableRouteManager { source, .. } => source.status_code(),
|
||||
Error::MissingDefaultValue { .. } => StatusCode::Internal,
|
||||
Error::MissingDefaultValue { .. } => StatusCode::IllegalState,
|
||||
Error::UnexpectedLogicalRouteTable { source, .. } => source.status_code(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,6 +358,7 @@ impl ErrorExt for Error {
|
||||
DataFusion { error, .. } => match error {
|
||||
DataFusionError::Internal(_) => StatusCode::Internal,
|
||||
DataFusionError::NotImplemented(_) => StatusCode::Unsupported,
|
||||
DataFusionError::ResourcesExhausted(_) => StatusCode::RuntimeResourcesExhausted,
|
||||
DataFusionError::Plan(_) => StatusCode::PlanQuery,
|
||||
_ => StatusCode::EngineExecuteQuery,
|
||||
},
|
||||
@@ -369,7 +370,7 @@ impl ErrorExt for Error {
|
||||
RegionQuery { source, .. } => source.status_code(),
|
||||
TableMutation { source, .. } => source.status_code(),
|
||||
MissingTableMutationHandler { .. } => StatusCode::Unexpected,
|
||||
GetRegionMetadata { .. } => StatusCode::Internal,
|
||||
GetRegionMetadata { .. } => StatusCode::RegionNotReady,
|
||||
TableReadOnly { .. } => StatusCode::Unsupported,
|
||||
GetFulltextOptions { source, .. } => source.status_code(),
|
||||
}
|
||||
|
||||
@@ -617,17 +617,20 @@ impl ErrorExt for Error {
|
||||
| TokioIo { .. }
|
||||
| StartHttp { .. }
|
||||
| StartGrpc { .. }
|
||||
| AlreadyStarted { .. }
|
||||
| InvalidPromRemoteReadQueryResult { .. }
|
||||
| TcpBind { .. }
|
||||
| SendPromRemoteRequest { .. }
|
||||
| TcpIncoming { .. }
|
||||
| CatalogError { .. }
|
||||
| GrpcReflectionService { .. }
|
||||
| BuildHttpResponse { .. }
|
||||
| Arrow { .. }
|
||||
| FileWatch { .. } => StatusCode::Internal,
|
||||
|
||||
AlreadyStarted { .. } | InvalidPromRemoteReadQueryResult { .. } => {
|
||||
StatusCode::IllegalState
|
||||
}
|
||||
|
||||
CatalogError { source, .. } => source.status_code(),
|
||||
|
||||
UnsupportedDataType { .. } => StatusCode::Unsupported,
|
||||
|
||||
#[cfg(not(windows))]
|
||||
|
||||
@@ -97,6 +97,7 @@ impl IntoResponse for ErrorResponse {
|
||||
| StatusCode::TableNotFound
|
||||
| StatusCode::TableColumnNotFound
|
||||
| StatusCode::PlanQuery
|
||||
| StatusCode::DatabaseAlreadyExists
|
||||
| StatusCode::FlowNotFound
|
||||
| StatusCode::FlowAlreadyExists => HttpStatusCode::BAD_REQUEST,
|
||||
|
||||
@@ -112,11 +113,13 @@ impl IntoResponse for ErrorResponse {
|
||||
StatusCode::RateLimited => HttpStatusCode::TOO_MANY_REQUESTS,
|
||||
|
||||
StatusCode::RegionNotReady
|
||||
| StatusCode::TableUnavailable
|
||||
| StatusCode::RegionBusy
|
||||
| StatusCode::StorageUnavailable => HttpStatusCode::SERVICE_UNAVAILABLE,
|
||||
|
||||
StatusCode::Internal
|
||||
| StatusCode::Unexpected
|
||||
| StatusCode::IllegalState
|
||||
| StatusCode::Unknown
|
||||
| StatusCode::RuntimeResourcesExhausted
|
||||
| StatusCode::EngineExecuteQuery => HttpStatusCode::INTERNAL_SERVER_ERROR,
|
||||
|
||||
@@ -21,8 +21,6 @@ use datafusion::error::DataFusionError;
|
||||
use datatypes::arrow::error::ArrowError;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
use crate::metadata::TableId;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
/// Default error implementation of table.
|
||||
@@ -84,13 +82,6 @@ pub enum Error {
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Duplicated call to plan execute method. table: {}", table))]
|
||||
DuplicatedExecuteCall {
|
||||
#[snafu(implicit)]
|
||||
location: Location,
|
||||
table: String,
|
||||
},
|
||||
|
||||
#[snafu(display(
|
||||
"Not allowed to remove index column {} from table {}",
|
||||
column_name,
|
||||
@@ -117,13 +108,6 @@ pub enum Error {
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Regions schemas mismatch in table: {}", table))]
|
||||
RegionSchemaMismatch {
|
||||
table: String,
|
||||
#[snafu(implicit)]
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to operate table"))]
|
||||
TableOperation { source: BoxedError },
|
||||
|
||||
@@ -146,13 +130,6 @@ pub enum Error {
|
||||
err: String,
|
||||
},
|
||||
|
||||
#[snafu(display("Invalid table state: {}", table_id))]
|
||||
InvalidTable {
|
||||
table_id: TableId,
|
||||
#[snafu(implicit)]
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Missing time index column in table: {}", table_name))]
|
||||
MissingTimeIndexColumn {
|
||||
table_name: String,
|
||||
@@ -170,20 +147,14 @@ impl ErrorExt for Error {
|
||||
Error::RemoveColumnInIndex { .. }
|
||||
| Error::BuildColumnDescriptor { .. }
|
||||
| Error::InvalidAlterRequest { .. } => StatusCode::InvalidArguments,
|
||||
Error::TablesRecordBatch { .. } | Error::DuplicatedExecuteCall { .. } => {
|
||||
StatusCode::Unexpected
|
||||
}
|
||||
Error::TablesRecordBatch { .. } => StatusCode::Unexpected,
|
||||
Error::ColumnExists { .. } => StatusCode::TableColumnExists,
|
||||
Error::SchemaBuild { source, .. } => source.status_code(),
|
||||
Error::TableOperation { source } => source.status_code(),
|
||||
Error::ColumnNotExists { .. } => StatusCode::TableColumnNotFound,
|
||||
Error::RegionSchemaMismatch { .. } => StatusCode::StorageUnavailable,
|
||||
Error::Unsupported { .. } => StatusCode::Unsupported,
|
||||
Error::ParseTableOption { .. } => StatusCode::InvalidArguments,
|
||||
|
||||
Error::InvalidTable { .. } | Error::MissingTimeIndexColumn { .. } => {
|
||||
StatusCode::Internal
|
||||
}
|
||||
Error::MissingTimeIndexColumn { .. } => StatusCode::IllegalState,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user