diff --git a/src/catalog/src/error.rs b/src/catalog/src/error.rs index 05c675d29566..6602aecbd4ac 100644 --- a/src/catalog/src/error.rs +++ b/src/catalog/src/error.rs @@ -180,7 +180,7 @@ pub enum Error { source: table::error::Error, }, - #[snafu(display(""))] + #[snafu(display("Internal error"))] Internal { location: Location, source: BoxedError, @@ -216,7 +216,7 @@ pub enum Error { #[snafu(display("Illegal access to catalog: {} and schema: {}", catalog, schema))] QueryAccessDenied { catalog: String, schema: String }, - #[snafu(display(""))] + #[snafu(display("DataFusion error"))] Datafusion { #[snafu(source)] error: DataFusionError, diff --git a/src/common/recordbatch/src/error.rs b/src/common/recordbatch/src/error.rs index e5992c37d916..188319ba1b44 100644 --- a/src/common/recordbatch/src/error.rs +++ b/src/common/recordbatch/src/error.rs @@ -55,7 +55,7 @@ pub enum Error { location: Location, }, - #[snafu(display(""))] + #[snafu(display("Failed to poll result stream"))] PollStream { #[snafu(source)] error: datafusion::error::DataFusionError, diff --git a/src/frontend/src/error.rs b/src/frontend/src/error.rs index 5f851768b2b8..b55cd398444d 100644 --- a/src/frontend/src/error.rs +++ b/src/frontend/src/error.rs @@ -44,7 +44,7 @@ pub enum Error { source: common_meta::error::Error, }, - #[snafu(display(""))] + #[snafu(display("External error"))] External { location: Location, source: BoxedError, @@ -170,7 +170,7 @@ pub enum Error { source: query::error::Error, }, - #[snafu(display(""))] + #[snafu(display("Operation to region server failed"))] InvokeRegionServer { location: Location, source: servers::error::Error, diff --git a/src/query/src/datafusion/error.rs b/src/query/src/datafusion/error.rs index d94fb0d89006..9d52c8fa9d97 100644 --- a/src/query/src/datafusion/error.rs +++ b/src/query/src/datafusion/error.rs @@ -25,7 +25,7 @@ use snafu::{Location, Snafu}; #[snafu(visibility(pub))] #[stack_trace_debug] pub enum InnerError { - #[snafu(display(""))] + #[snafu(display("DataFusion error"))] Datafusion { #[snafu(source)] error: DataFusionError, diff --git a/src/query/src/error.rs b/src/query/src/error.rs index 7999b4b49871..cbe8256215be 100644 --- a/src/query/src/error.rs +++ b/src/query/src/error.rs @@ -121,7 +121,7 @@ pub enum Error { location: Location, }, - #[snafu(display(""))] + #[snafu(display("DataFusion error"))] DataFusion { #[snafu(source)] error: DataFusionError, @@ -140,7 +140,7 @@ pub enum Error { source: sql::error::Error, }, - #[snafu(display(""))] + #[snafu(display("Failed to plan SQL"))] PlanSql { #[snafu(source)] error: DataFusionError, diff --git a/src/script/src/python/error.rs b/src/script/src/python/error.rs index 376f734af693..ad00998f3a4c 100644 --- a/src/script/src/python/error.rs +++ b/src/script/src/python/error.rs @@ -76,7 +76,7 @@ pub enum Error { error: ArrowError, }, - #[snafu(display(""))] + #[snafu(display("DataFusion error"))] DataFusion { location: SnafuLocation, #[snafu(source)] diff --git a/src/servers/src/error.rs b/src/servers/src/error.rs index 2cf9cf8b89ae..35e8dc301679 100644 --- a/src/servers/src/error.rs +++ b/src/servers/src/error.rs @@ -339,8 +339,12 @@ pub enum Error { source: crate::http::pprof::nix::Error, }, - #[snafu(display(""))] - Metrics { source: BoxedError }, + #[snafu(display("Failed to update jemalloc metrics"))] + UpdateJemallocMetrics { + #[snafu(source)] + error: tikv_jemalloc_ctl::Error, + location: Location, + }, #[snafu(display("DataFrame operation error"))] DataFrame { @@ -408,7 +412,8 @@ impl ErrorExt for Error { | TcpIncoming { .. } | CatalogError { .. } | GrpcReflectionService { .. } - | BuildHttpResponse { .. } => StatusCode::Internal, + | BuildHttpResponse { .. } + | UpdateJemallocMetrics { .. } => StatusCode::Internal, CollectRecordbatch { .. } => StatusCode::EngineExecuteQuery, @@ -479,8 +484,6 @@ impl ErrorExt for Error { #[cfg(feature = "pprof")] DumpPprof { source, .. } => source.status_code(), - Metrics { source } => source.status_code(), - ConvertScalarValue { source, .. } => source.status_code(), ToJson { .. } => StatusCode::Internal, diff --git a/src/servers/src/metrics/jemalloc.rs b/src/servers/src/metrics/jemalloc.rs index 26cf5a21ac50..6b977301360f 100644 --- a/src/servers/src/metrics/jemalloc.rs +++ b/src/servers/src/metrics/jemalloc.rs @@ -12,10 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -mod error; - use common_telemetry::error; -use error::UpdateJemallocMetricsSnafu; use lazy_static::lazy_static; use once_cell::sync::Lazy; use prometheus::*; @@ -23,6 +20,8 @@ use snafu::ResultExt; use tikv_jemalloc_ctl::stats::{allocated_mib, resident_mib}; use tikv_jemalloc_ctl::{epoch, epoch_mib, stats}; +use crate::error::UpdateJemallocMetricsSnafu; + lazy_static! { pub static ref SYS_JEMALLOC_RESIDEN: IntGauge = register_int_gauge!( "sys_jemalloc_resident", diff --git a/src/servers/src/metrics/jemalloc/error.rs b/src/servers/src/metrics/jemalloc/error.rs deleted file mode 100644 index 14c125ce6f86..000000000000 --- a/src/servers/src/metrics/jemalloc/error.rs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2023 Greptime Team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use std::any::Any; - -use common_error::ext::{BoxedError, ErrorExt}; -use common_error::status_code::StatusCode; -use common_macro::stack_trace_debug; -use snafu::{Location, Snafu}; - -#[derive(Snafu)] -#[snafu(visibility(pub))] -#[stack_trace_debug] -pub enum Error { - #[snafu(display("Failed to update jemalloc metrics"))] - UpdateJemallocMetrics { - #[snafu(source)] - error: tikv_jemalloc_ctl::Error, - location: Location, - }, -} - -impl ErrorExt for Error { - fn status_code(&self) -> StatusCode { - match self { - Error::UpdateJemallocMetrics { .. } => StatusCode::Internal, - } - } - - fn as_any(&self) -> &dyn Any { - self - } -} - -impl From for crate::error::Error { - fn from(e: Error) -> Self { - Self::Metrics { - source: BoxedError::new(e), - } - } -} diff --git a/src/table/src/error.rs b/src/table/src/error.rs index 6ac4c970fe9e..5d034d09e2c3 100644 --- a/src/table/src/error.rs +++ b/src/table/src/error.rs @@ -30,7 +30,7 @@ pub type Result = std::result::Result; #[snafu(visibility(pub))] #[stack_trace_debug] pub enum Error { - #[snafu(display(""))] + #[snafu(display("DataFusion error"))] Datafusion { #[snafu(source)] error: DataFusionError,