diff --git a/Cargo.lock b/Cargo.lock index a28d8ad50583..0c28c00e3291 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2621,8 +2621,6 @@ dependencies = [ "bincode 2.0.0-rc.3", "codespan-reporting 0.11.1 (git+https://github.com/brendanzab/codespan?rev=c84116f5)", "databend-common-arrow", - "databend-common-meta-stoerr", - "databend-common-meta-types", "http", "opendal", "parquet", @@ -3077,6 +3075,7 @@ name = "databend-common-meta-stoerr" version = "0.1.0" dependencies = [ "anyerror", + "databend-common-exception", "prost 0.12.1", "serde", "serde_json", @@ -3105,6 +3104,7 @@ dependencies = [ "anyerror", "anyhow", "databend-common-building", + "databend-common-exception", "databend-common-meta-stoerr", "derive_more", "num-derive", diff --git a/src/common/exception/Cargo.toml b/src/common/exception/Cargo.toml index a95ceed2af11..d8cf94e94aff 100644 --- a/src/common/exception/Cargo.toml +++ b/src/common/exception/Cargo.toml @@ -12,8 +12,6 @@ test = false [dependencies] # In alphabetical order databend-common-arrow = { path = "../arrow" } -databend-common-meta-stoerr = { path = "../../meta/stoerr" } -databend-common-meta-types = { path = "../../meta/types" } # GitHub dependencies # TODO: Use the version from crates.io once diff --git a/src/common/exception/src/exception_into.rs b/src/common/exception/src/exception_into.rs index a24b7cfaefc1..ee91f2177741 100644 --- a/src/common/exception/src/exception_into.rs +++ b/src/common/exception/src/exception_into.rs @@ -18,10 +18,6 @@ use std::fmt::Display; use std::fmt::Formatter; use std::sync::Arc; -use databend_common_meta_stoerr::MetaStorageError; -use databend_common_meta_types::MetaAPIError; -use databend_common_meta_types::MetaError; - use crate::exception::ErrorCodeBacktrace; use crate::exception_backtrace::capture; use crate::ErrorCode; @@ -328,24 +324,6 @@ impl From for ErrorCode { } } -impl From for ErrorCode { - fn from(e: MetaError) -> Self { - ErrorCode::MetaServiceError(e.to_string()) - } -} - -impl From for ErrorCode { - fn from(e: MetaAPIError) -> Self { - ErrorCode::MetaServiceError(e.to_string()) - } -} - -impl From for ErrorCode { - fn from(e: MetaStorageError) -> Self { - ErrorCode::MetaServiceError(e.to_string()) - } -} - impl From for tonic::Status { fn from(err: ErrorCode) -> Self { let error_json = serde_json::to_vec::(&SerializedError { diff --git a/src/meta/stoerr/Cargo.toml b/src/meta/stoerr/Cargo.toml index d5e9b6025071..2465846a484b 100644 --- a/src/meta/stoerr/Cargo.toml +++ b/src/meta/stoerr/Cargo.toml @@ -11,6 +11,7 @@ doctest = false test = true [dependencies] +databend-common-exception = { path = "../../common/exception" } anyerror = { workspace = true } prost = { workspace = true } diff --git a/src/meta/stoerr/src/meta_storage_errors.rs b/src/meta/stoerr/src/meta_storage_errors.rs index e8a086a6a3a0..23ef0dcdce10 100644 --- a/src/meta/stoerr/src/meta_storage_errors.rs +++ b/src/meta/stoerr/src/meta_storage_errors.rs @@ -16,6 +16,7 @@ use std::fmt; use std::io; use anyerror::AnyError; +use databend_common_exception::ErrorCode; use serde::Deserialize; use serde::Serialize; use sled::transaction::UnabortableTransactionError; @@ -101,3 +102,9 @@ impl From for io::Error { io::Error::new(io::ErrorKind::InvalidData, e) } } + +impl From for ErrorCode { + fn from(e: MetaStorageError) -> Self { + ErrorCode::MetaServiceError(e.to_string()) + } +} diff --git a/src/meta/types/Cargo.toml b/src/meta/types/Cargo.toml index bd22c90aa7f0..8f60d7938b1d 100644 --- a/src/meta/types/Cargo.toml +++ b/src/meta/types/Cargo.toml @@ -11,6 +11,7 @@ doctest = false test = true [dependencies] +databend-common-exception = { path = "../../common/exception" } databend-common-meta-stoerr = { path = "../stoerr" } openraft = { workspace = true } diff --git a/src/meta/types/src/errors/meta_api_errors.rs b/src/meta/types/src/errors/meta_api_errors.rs index 0b9f8ba74543..684c0a0ad5b3 100644 --- a/src/meta/types/src/errors/meta_api_errors.rs +++ b/src/meta/types/src/errors/meta_api_errors.rs @@ -15,6 +15,7 @@ use std::fmt::Display; use anyerror::AnyError; +use databend_common_exception::ErrorCode; use tonic::Status; use crate::errors; @@ -202,3 +203,9 @@ impl From> for MetaAPIError { } } } + +impl From for ErrorCode { + fn from(e: MetaAPIError) -> Self { + ErrorCode::MetaServiceError(e.to_string()) + } +} diff --git a/src/meta/types/src/errors/meta_errors.rs b/src/meta/types/src/errors/meta_errors.rs index 8df6d4a8ef0e..79031d721649 100644 --- a/src/meta/types/src/errors/meta_errors.rs +++ b/src/meta/types/src/errors/meta_errors.rs @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +use databend_common_exception::ErrorCode; use databend_common_meta_stoerr::MetaStorageError; use serde::Deserialize; use serde::Serialize; @@ -72,3 +73,9 @@ impl From for MetaError { Self::ClientError(client_err) } } + +impl From for ErrorCode { + fn from(e: MetaError) -> Self { + ErrorCode::MetaServiceError(e.to_string()) + } +} diff --git a/src/query/config/Cargo.toml b/src/query/config/Cargo.toml index 88694103de45..9b798567d933 100644 --- a/src/query/config/Cargo.toml +++ b/src/query/config/Cargo.toml @@ -16,7 +16,6 @@ storage-hdfs = ["databend-common-storage/storage-hdfs"] ignored = ["strum"] [dependencies] -chrono-tz = { workspace = true } databend-common-base = { path = "../../common/base" } databend-common-exception = { path = "../../common/exception" } databend-common-grpc = { path = "../../common/grpc" } @@ -25,6 +24,7 @@ databend-common-storage = { path = "../../common/storage" } databend-common-tracing = { path = "../../common/tracing" } databend-common-users = { path = "../users" } +chrono-tz = { workspace = true } clap = { workspace = true } hex = "0.4.3" log = { workspace = true }