Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: common-exception crate should be independent of meta-types #14275

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/common/exception/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions src/common/exception/src/exception_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -328,24 +324,6 @@ impl From<tonic::Status> for ErrorCode {
}
}

impl From<MetaError> for ErrorCode {
fn from(e: MetaError) -> Self {
ErrorCode::MetaServiceError(e.to_string())
}
}

impl From<MetaAPIError> for ErrorCode {
fn from(e: MetaAPIError) -> Self {
ErrorCode::MetaServiceError(e.to_string())
}
}

impl From<MetaStorageError> for ErrorCode {
fn from(e: MetaStorageError) -> Self {
ErrorCode::MetaServiceError(e.to_string())
}
}

impl From<ErrorCode> for tonic::Status {
fn from(err: ErrorCode) -> Self {
let error_json = serde_json::to_vec::<SerializedError>(&SerializedError {
Expand Down
1 change: 1 addition & 0 deletions src/meta/stoerr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ doctest = false
test = true

[dependencies]
databend-common-exception = { path = "../../common/exception" }

anyerror = { workspace = true }
prost = { workspace = true }
Expand Down
7 changes: 7 additions & 0 deletions src/meta/stoerr/src/meta_storage_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -101,3 +102,9 @@ impl From<MetaStorageError> for io::Error {
io::Error::new(io::ErrorKind::InvalidData, e)
}
}

impl From<MetaStorageError> for ErrorCode {
fn from(e: MetaStorageError) -> Self {
ErrorCode::MetaServiceError(e.to_string())
}
}
1 change: 1 addition & 0 deletions src/meta/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ doctest = false
test = true

[dependencies]
databend-common-exception = { path = "../../common/exception" }
databend-common-meta-stoerr = { path = "../stoerr" }

openraft = { workspace = true }
Expand Down
7 changes: 7 additions & 0 deletions src/meta/types/src/errors/meta_api_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use std::fmt::Display;

use anyerror::AnyError;
use databend_common_exception::ErrorCode;
use tonic::Status;

use crate::errors;
Expand Down Expand Up @@ -202,3 +203,9 @@ impl From<RaftError<ClientWriteError>> for MetaAPIError {
}
}
}

impl From<MetaAPIError> for ErrorCode {
fn from(e: MetaAPIError) -> Self {
ErrorCode::MetaServiceError(e.to_string())
}
}
7 changes: 7 additions & 0 deletions src/meta/types/src/errors/meta_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -72,3 +73,9 @@ impl From<errors::IncompleteStream> for MetaError {
Self::ClientError(client_err)
}
}

impl From<MetaError> for ErrorCode {
fn from(e: MetaError) -> Self {
ErrorCode::MetaServiceError(e.to_string())
}
}
2 changes: 1 addition & 1 deletion src/query/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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 }
Expand Down
Loading