From 63749af3c4f139d706ca5777de1b7c0df789b583 Mon Sep 17 00:00:00 2001 From: shuiyisong Date: Mon, 18 Sep 2023 14:53:02 +0800 Subject: [PATCH] refactor: remove location pt 1 --- src/client/src/error.rs | 2 +- src/common/meta/src/error.rs | 4 +- src/common/recordbatch/src/error.rs | 2 +- src/datanode/src/error.rs | 31 +++----- src/meta-srv/src/error.rs | 6 +- src/mito2/src/error.rs | 116 +++++++++++----------------- src/promql/src/error.rs | 49 +++++------- src/query/src/error.rs | 8 +- src/servers/src/error.rs | 2 +- src/servers/src/http/pprof/nix.rs | 8 +- src/storage/src/error.rs | 2 +- src/store-api/src/metadata.rs | 17 ++-- 12 files changed, 93 insertions(+), 154 deletions(-) diff --git a/src/client/src/error.rs b/src/client/src/error.rs index e6d6f6cf5ad7..e53465054e07 100644 --- a/src/client/src/error.rs +++ b/src/client/src/error.rs @@ -33,7 +33,7 @@ pub enum Error { source: BoxedError, }, - #[snafu(display("Failure occurs during handling request, location: {}", location))] + #[snafu(display("Failure occurs during handling request"))] HandleRequest { location: Location, source: BoxedError, diff --git a/src/common/meta/src/error.rs b/src/common/meta/src/error.rs index 0adc7c987b97..7ab7cff87087 100644 --- a/src/common/meta/src/error.rs +++ b/src/common/meta/src/error.rs @@ -59,7 +59,7 @@ pub enum Error { source: common_procedure::Error, }, - #[snafu(display("Unsupported operation {}, location: {}", operation, location))] + #[snafu(display("Unsupported operation {}", operation))] Unsupported { operation: String, location: Location, @@ -226,7 +226,7 @@ pub enum Error { source: BoxedError, }, - #[snafu(display("Invalid heartbeat response, location: {}", location))] + #[snafu(display("Invalid heartbeat response"))] InvalidHeartbeatResponse { location: Location }, #[snafu(display("Failed to operate on datanode: {}", peer))] diff --git a/src/common/recordbatch/src/error.rs b/src/common/recordbatch/src/error.rs index 0b489cb2e767..2ddfe27e2d13 100644 --- a/src/common/recordbatch/src/error.rs +++ b/src/common/recordbatch/src/error.rs @@ -37,7 +37,7 @@ pub enum Error { source: datatypes::error::Error, }, - #[snafu(display("External error, location: {}", location))] + #[snafu(display("External error"))] External { location: Location, source: BoxedError, diff --git a/src/datanode/src/error.rs b/src/datanode/src/error.rs index 3713bafcd029..b26de2dfb3f3 100644 --- a/src/datanode/src/error.rs +++ b/src/datanode/src/error.rs @@ -200,7 +200,7 @@ pub enum Error { #[snafu(display("Expect KvBackend but not found"))] MissingKvBackend { location: Location }, - #[snafu(display("Expect MetaClient but not found, location: {}", location))] + #[snafu(display("Expect MetaClient but not found"))] MissingMetaClient { location: Location }, #[snafu(display("Invalid SQL, error: {}", msg))] @@ -280,10 +280,10 @@ pub enum Error { source: table::error::Error, }, - #[snafu(display("Missing node id in Datanode config, location: {}", location))] + #[snafu(display("Missing node id in Datanode config"))] MissingNodeId { location: Location }, - #[snafu(display("Missing node id option in distributed mode, location: {}", location))] + #[snafu(display("Missing node id option in distributed mode"))] MissingMetasrvOpts { location: Location }, #[snafu(display("Missing required field: {}", name))] @@ -367,44 +367,35 @@ pub enum Error { location: Location, }, - #[snafu(display( - "Failed to handle request for region {}, location: {}", - region_id, - location - ))] + #[snafu(display("Failed to handle request for region {}", region_id))] HandleRegionRequest { region_id: RegionId, location: Location, source: BoxedError, }, - #[snafu(display("RegionId {} not found, location: {}", region_id, location))] + #[snafu(display("RegionId {} not found", region_id))] RegionNotFound { region_id: RegionId, location: Location, }, - #[snafu(display("Region engine {} is not registered, location: {}", name, location))] + #[snafu(display("Region engine {} is not registered", name))] RegionEngineNotFound { name: String, location: Location }, - #[snafu(display("Unsupported gRPC request, kind: {}, location: {}", kind, location))] + #[snafu(display("Unsupported gRPC request, kind: {}", kind))] UnsupportedGrpcRequest { kind: String, location: Location }, - #[snafu(display( - "Unsupported output type, expected: {}, location: {}", - expected, - location - ))] + #[snafu(display("Unsupported output type, expected: {}", expected))] UnsupportedOutput { expected: String, location: Location, }, #[snafu(display( - "Failed to get metadata from engine {} for region_id {}, location: {}", + "Failed to get metadata from engine {} for region_id {}", engine, region_id, - location, ))] GetRegionMetadata { engine: String, @@ -413,13 +404,13 @@ pub enum Error { source: BoxedError, }, - #[snafu(display("Failed to build region requests, location:{}", location))] + #[snafu(display("Failed to build region requests"))] BuildRegionRequests { location: Location, source: store_api::metadata::MetadataError, }, - #[snafu(display("Failed to stop region engine {}, location:{}", name, location))] + #[snafu(display("Failed to stop region engine {}", name))] StopRegionEngine { name: String, location: Location, diff --git a/src/meta-srv/src/error.rs b/src/meta-srv/src/error.rs index 8c782a208eb3..47e5262478c2 100644 --- a/src/meta-srv/src/error.rs +++ b/src/meta-srv/src/error.rs @@ -122,7 +122,7 @@ pub enum Error { #[snafu(display("Empty key is not allowed"))] EmptyKey { location: Location }, - #[snafu(display("Failed to execute via Etcd, location: {}", location))] + #[snafu(display("Failed to execute via Etcd"))] EtcdFailed { source: etcd_client::Error, location: Location, @@ -498,10 +498,10 @@ pub enum Error { location: Location, }, - #[snafu(display("Too many partitions, location: {}", location))] + #[snafu(display("Too many partitions"))] TooManyPartitions { location: Location }, - #[snafu(display("Unsupported operation {}, location: {}", operation, location))] + #[snafu(display("Unsupported operation {}", operation))] Unsupported { operation: String, location: Location, diff --git a/src/mito2/src/error.rs b/src/mito2/src/error.rs index bfb509c4daeb..114211925f2b 100644 --- a/src/mito2/src/error.rs +++ b/src/mito2/src/error.rs @@ -32,7 +32,7 @@ use crate::worker::WorkerId; #[derive(Debug, Snafu)] #[snafu(visibility(pub))] pub enum Error { - #[snafu(display("OpenDAL operator failed. Location: {}", location))] + #[snafu(display("OpenDAL operator failed"))] OpenDal { location: Location, source: object_store::Error, @@ -52,7 +52,7 @@ pub enum Error { source: std::io::Error, }, - #[snafu(display("Failed to ser/de json object. Location: {}", location))] + #[snafu(display("Failed to ser/de json object"))] SerdeJson { location: Location, source: serde_json::Error, @@ -65,83 +65,78 @@ pub enum Error { location: Location, }, - #[snafu(display("Invalid UTF-8 content. Location: {}", location))] + #[snafu(display("Invalid UTF-8 content"))] Utf8 { location: Location, source: std::str::Utf8Error, }, - #[snafu(display("Cannot find RegionMetadata. Location: {}", location))] + #[snafu(display("Cannot find RegionMetadata"))] RegionMetadataNotFound { location: Location }, - #[snafu(display("Failed to join handle, location: {}", location))] + #[snafu(display("Failed to join handle"))] Join { source: common_runtime::JoinError, location: Location, }, - #[snafu(display("Worker {} is stopped, location: {}", id, location))] + #[snafu(display("Worker {} is stopped", id))] WorkerStopped { id: WorkerId, location: Location }, - #[snafu(display("Failed to recv result, location: {}", location))] + #[snafu(display("Failed to recv result"))] Recv { source: tokio::sync::oneshot::error::RecvError, location: Location, }, - #[snafu(display("Invalid metadata, {}, location: {}", reason, location))] + #[snafu(display("Invalid metadata, {}", reason))] InvalidMeta { reason: String, location: Location }, - #[snafu(display("Invalid region metadata, location: {}", location))] + #[snafu(display("Invalid region metadata"))] InvalidMetadata { source: store_api::metadata::MetadataError, location: Location, }, - #[snafu(display("Region {} already exists, location: {}", region_id, location))] + #[snafu(display("Region {} already exists", region_id))] RegionExists { region_id: RegionId, location: Location, }, - #[snafu(display("Failed to create RecordBatch from vectors, location: {}", location))] + #[snafu(display("Failed to create RecordBatch from vectors"))] NewRecordBatch { location: Location, source: ArrowError, }, - #[snafu(display("Failed to write to buffer, location: {}", location))] + #[snafu(display("Failed to write to buffer"))] WriteBuffer { location: Location, source: common_datasource::error::Error, }, - #[snafu(display("Failed to write parquet file, path: {}, location: {}", path, location,))] + #[snafu(display("Failed to write parquet file, path: {}", path))] WriteParquet { path: String, location: Location, source: parquet::errors::ParquetError, }, - #[snafu(display("Failed to read parquet file, path: {}, location: {}", path, location,))] + #[snafu(display("Failed to read parquet file, path: {}", path))] ReadParquet { path: String, source: parquet::errors::ParquetError, location: Location, }, - #[snafu(display("Region {} not found, location: {}", region_id, location))] + #[snafu(display("Region {} not found", region_id))] RegionNotFound { region_id: RegionId, location: Location, }, - #[snafu(display( - "Region {} is corrupted, reason: {}, location: {}", - region_id, - reason, - location - ))] + #[snafu(display("Region {} is corrupted, reason: {}", region_id, reason))] RegionCorrupted { region_id: RegionId, reason: String, @@ -174,46 +169,34 @@ pub enum Error { source: datatypes::Error, }, - #[snafu(display( - "Failed to encode WAL entry, region_id: {}, location: {}", - region_id, - location, - ))] + #[snafu(display("Failed to encode WAL entry, region_id: {}", region_id))] EncodeWal { region_id: RegionId, location: Location, source: EncodeError, }, - #[snafu(display("Failed to write WAL, location: {}", location))] + #[snafu(display("Failed to write WAL"))] WriteWal { location: Location, source: BoxedError, }, - #[snafu(display("Failed to read WAL, region_id: {}, location: {}", region_id, location,))] + #[snafu(display("Failed to read WAL, region_id: {}", region_id))] ReadWal { region_id: RegionId, location: Location, source: BoxedError, }, - #[snafu(display( - "Failed to decode WAL entry, region_id: {}, location: {}", - region_id, - location, - ))] + #[snafu(display("Failed to decode WAL entry, region_id: {}", region_id))] DecodeWal { region_id: RegionId, location: Location, source: DecodeError, }, - #[snafu(display( - "Failed to delete WAL, region_id: {}, location: {}", - region_id, - location, - ))] + #[snafu(display("Failed to delete WAL, region_id: {}", region_id))] DeleteWal { region_id: RegionId, location: Location, @@ -227,89 +210,78 @@ pub enum Error { #[snafu(display("Row value mismatches field data type"))] FieldTypeMismatch { source: datatypes::error::Error }, - #[snafu(display("Failed to serialize field, location: {}", location))] + #[snafu(display("Failed to serialize field"))] SerializeField { source: memcomparable::Error, location: Location, }, #[snafu(display( - "Data type: {} does not support serialization/deserialization, location: {}", + "Data type: {} does not support serialization/deserialization", data_type, - location ))] NotSupportedField { data_type: ConcreteDataType, location: Location, }, - #[snafu(display("Failed to deserialize field, location: {}", location))] + #[snafu(display("Failed to deserialize field"))] DeserializeField { source: memcomparable::Error, location: Location, }, - #[snafu(display( - "Invalid parquet SST file {}, location: {}, reason: {}", - file, - location, - reason - ))] + #[snafu(display("Invalid parquet SST file {}, reason: {}", file, reason))] InvalidParquet { file: String, reason: String, location: Location, }, - #[snafu(display("Invalid batch, {}, location: {}", reason, location))] + #[snafu(display("Invalid batch, {}", reason))] InvalidBatch { reason: String, location: Location }, - #[snafu(display("Invalid arrow record batch, {}, location: {}", reason, location))] + #[snafu(display("Invalid arrow record batch, {}", reason))] InvalidRecordBatch { reason: String, location: Location }, - #[snafu(display("Failed to convert array to vector, location: {}", location))] + #[snafu(display("Failed to convert array to vector"))] ConvertVector { location: Location, source: datatypes::error::Error, }, - #[snafu(display("Failed to compute arrow arrays, location: {}", location))] + #[snafu(display("Failed to compute arrow arrays"))] ComputeArrow { location: Location, source: datatypes::arrow::error::ArrowError, }, - #[snafu(display("Failed to compute vector, location: {}", location))] + #[snafu(display("Failed to compute vector"))] ComputeVector { location: Location, source: datatypes::error::Error, }, - #[snafu(display( - "Primary key length mismatch, expect: {}, actual: {}, location: {}", - expect, - actual, - location - ))] + #[snafu(display("Primary key length mismatch, expect: {}, actual: {}", expect, actual))] PrimaryKeyLengthMismatch { expect: usize, actual: usize, location: Location, }, - #[snafu(display("Invalid sender, location: {}", location,))] + #[snafu(display("Invalid sender",))] InvalidSender { location: Location }, - #[snafu(display("Invalid scheduler state, location: {}", location))] + #[snafu(display("Invalid scheduler state"))] InvalidSchedulerState { location: Location }, - #[snafu(display("Failed to stop scheduler, location: {}", location))] + #[snafu(display("Failed to stop scheduler"))] StopScheduler { source: JoinError, location: Location, }, - #[snafu(display("Failed to build scan predicate, location: {}", location))] + #[snafu(display("Failed to build scan predicate"))] BuildPredicate { source: table::error::Error, location: Location, @@ -322,42 +294,41 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to flush region {}, location: {}", region_id, location))] + #[snafu(display("Failed to flush region {}", region_id))] FlushRegion { region_id: RegionId, source: Arc, location: Location, }, - #[snafu(display("Region {} is dropped, location: {}", region_id, location))] + #[snafu(display("Region {} is dropped", region_id))] RegionDropped { region_id: RegionId, location: Location, }, - #[snafu(display("Region {} is closed, location: {}", region_id, location))] + #[snafu(display("Region {} is closed", region_id))] RegionClosed { region_id: RegionId, location: Location, }, - #[snafu(display("Region {} is truncated, location: {}", region_id, location))] + #[snafu(display("Region {} is truncated", region_id))] RegionTruncated { region_id: RegionId, location: Location, }, #[snafu(display( - "Engine write buffer is full, rejecting write requests of region {}, location: {}", + "Engine write buffer is full, rejecting write requests of region {}", region_id, - location ))] RejectWrite { region_id: RegionId, location: Location, }, - #[snafu(display("Failed to compact region {}, location: {}", region_id, location))] + #[snafu(display("Failed to compact region {}", region_id))] CompactRegion { region_id: RegionId, source: Arc, @@ -365,10 +336,9 @@ pub enum Error { }, #[snafu(display( - "Failed to compat readers for region {}, reason: {}, location: {}", + "Failed to compat readers for region {}, reason: {}", region_id, reason, - location ))] CompatReader { region_id: RegionId, @@ -382,7 +352,7 @@ pub enum Error { location: Location, }, - #[snafu(display("Region {} is read only, location: {}", region_id, location))] + #[snafu(display("Region {} is read only", region_id))] RegionReadonly { region_id: RegionId, location: Location, diff --git a/src/promql/src/error.rs b/src/promql/src/error.rs index 1126e5e5ccf3..ead6948aa12b 100644 --- a/src/promql/src/error.rs +++ b/src/promql/src/error.rs @@ -23,59 +23,46 @@ use snafu::{Location, Snafu}; #[derive(Debug, Snafu)] #[snafu(visibility(pub))] pub enum Error { - #[snafu(display("Unsupported expr type: {}, location: {}", name, location))] + #[snafu(display("Unsupported expr type: {}", name))] UnsupportedExpr { name: String, location: Location }, - #[snafu(display("Unexpected token: {:?}, location: {}", token, location))] + #[snafu(display("Unexpected token: {:?}", token))] UnexpectedToken { token: TokenType, location: Location, }, - #[snafu(display( - "Internal error during building DataFusion plan, location: {}", - location - ))] + #[snafu(display("Internal error during building DataFusion plan"))] DataFusionPlanning { source: datafusion::error::DataFusionError, location: Location, }, - #[snafu(display("Unexpected plan or expression: {}, location: {}", desc, location))] + #[snafu(display("Unexpected plan or expression: {}", desc))] UnexpectedPlanExpr { desc: String, location: Location }, - #[snafu(display("Unknown table type, downcast failed, location: {}", location))] + #[snafu(display("Unknown table type, downcast failed"))] UnknownTable { location: Location }, - #[snafu(display( - "Cannot find time index column in table {}, location: {}", - table, - location - ))] + #[snafu(display("Cannot find time index column in table {}", table))] TimeIndexNotFound { table: String, location: Location }, - #[snafu(display("Cannot find value columns in table {}, location: {}", table, location))] + #[snafu(display("Cannot find value columns in table {}", table))] ValueNotFound { table: String, location: Location }, #[snafu(display( - "Cannot accept multiple vector as function input, PromQL expr: {:?}, location: {}", + "Cannot accept multiple vector as function input, PromQL expr: {:?}", expr, - location ))] MultipleVector { expr: PromExpr, location: Location }, - #[snafu(display( - "Expect a PromQL expr but not found, input expr: {:?}, location: {}", - expr, - location - ))] + #[snafu(display("Expect a PromQL expr but not found, input expr: {:?}", expr))] ExpectExpr { expr: PromExpr, location: Location }, #[snafu(display( - "Illegal range: offset {}, length {}, array len {}, location: {}", + "Illegal range: offset {}, length {}, array len {}", offset, length, len, - location ))] IllegalRange { offset: u32, @@ -90,33 +77,33 @@ pub enum Error { location: Location, }, - #[snafu(display("Empty range is not expected, location: {}", location))] + #[snafu(display("Empty range is not expected"))] EmptyRange { location: Location }, #[snafu(display( - "Table (metric) name not found, this indicates a procedure error in PromQL planner, location: {}", location + "Table (metric) name not found, this indicates a procedure error in PromQL planner" ))] TableNameNotFound { location: Location }, - #[snafu(display("General catalog error: , location: {}", location))] + #[snafu(display("General catalog error: "))] Catalog { location: Location, source: catalog::error::Error, }, - #[snafu(display("Expect a range selector, but not found, location: {}", location))] + #[snafu(display("Expect a range selector, but not found"))] ExpectRangeSelector { location: Location }, - #[snafu(display("Zero range in range selector, location: {}", location))] + #[snafu(display("Zero range in range selector"))] ZeroRangeSelector { location: Location }, - #[snafu(display("Cannot find column {col}, location: {}", location))] + #[snafu(display("Cannot find column {col}"))] ColumnNotFound { col: String, location: Location }, - #[snafu(display("Found multiple metric matchers in selector, location: {}", location))] + #[snafu(display("Found multiple metric matchers in selector"))] MultipleMetricMatchers { location: Location }, - #[snafu(display("Expect a metric matcher, but not found, location: {}", location))] + #[snafu(display("Expect a metric matcher, but not found"))] NoMetricMatcher { location: Location }, } diff --git a/src/query/src/error.rs b/src/query/src/error.rs index 2f275f3caf82..725895711438 100644 --- a/src/query/src/error.rs +++ b/src/query/src/error.rs @@ -226,14 +226,10 @@ pub enum Error { source: datatypes::error::Error, location: Location, }, - #[snafu(display("Unknown table type, downcast failed, location: {}", location))] + #[snafu(display("Unknown table type, downcast failed"))] UnknownTable { location: Location }, - #[snafu(display( - "Cannot find time index column in table {}, location: {}", - table, - location - ))] + #[snafu(display("Cannot find time index column in table {}", table))] TimeIndexNotFound { table: String, location: Location }, #[snafu(display("Failed to add duration '{:?}' to SystemTime, overflowed", duration))] diff --git a/src/servers/src/error.rs b/src/servers/src/error.rs index 92cc149d804b..97f52786bd3b 100644 --- a/src/servers/src/error.rs +++ b/src/servers/src/error.rs @@ -65,7 +65,7 @@ pub enum Error { source: std::io::Error, }, - #[snafu(display("Failed to execute query, query: {}, location: {}", query, location))] + #[snafu(display("Failed to execute query, query: {}", query))] ExecuteQuery { query: String, location: Location, diff --git a/src/servers/src/http/pprof/nix.rs b/src/servers/src/http/pprof/nix.rs index 0fb46b77bc9e..5c87bd0362c5 100644 --- a/src/servers/src/http/pprof/nix.rs +++ b/src/servers/src/http/pprof/nix.rs @@ -22,25 +22,25 @@ use snafu::{Location, ResultExt, Snafu}; #[derive(Debug, Snafu)] pub enum Error { - #[snafu(display("Failed to create profiler guard, location: {}", location))] + #[snafu(display("Failed to create profiler guard"))] CreateGuard { source: pprof::Error, location: Location, }, - #[snafu(display("Failed to create report, location: {}", location))] + #[snafu(display("Failed to create report"))] CreateReport { source: pprof::Error, location: Location, }, - #[snafu(display("Failed to create flamegraph, location: {}", location))] + #[snafu(display("Failed to create flamegraph"))] CreateFlamegraph { source: pprof::Error, location: Location, }, - #[snafu(display("Failed to create pprof report, location: {}", location))] + #[snafu(display("Failed to create pprof report"))] ReportPprof { source: pprof::Error, location: Location, diff --git a/src/storage/src/error.rs b/src/storage/src/error.rs index 8224b46a8c8b..7ad09595a211 100644 --- a/src/storage/src/error.rs +++ b/src/storage/src/error.rs @@ -492,7 +492,7 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to join spawned tasks, location: {}", location))] + #[snafu(display("Failed to join spawned tasks"))] JoinError { source: JoinError, location: Location, diff --git a/src/store-api/src/metadata.rs b/src/store-api/src/metadata.rs index a607d41c1f05..5132c0b17e6f 100644 --- a/src/store-api/src/metadata.rs +++ b/src/store-api/src/metadata.rs @@ -553,36 +553,31 @@ impl SkippedFields { #[derive(Debug, Snafu)] #[snafu(visibility(pub))] pub enum MetadataError { - #[snafu(display("Invalid schema, location: {}", location))] + #[snafu(display("Invalid schema"))] InvalidSchema { source: datatypes::error::Error, location: Location, }, - #[snafu(display("Invalid metadata, {}, location: {}", reason, location))] + #[snafu(display("Invalid metadata, {}", reason))] InvalidMeta { reason: String, location: Location }, - #[snafu(display("Failed to ser/de json object. Location: {}", location))] + #[snafu(display("Failed to ser/de json object"))] SerdeJson { location: Location, source: serde_json::Error, }, - #[snafu(display("Failed to convert struct from datatypes, location: {}", location))] + #[snafu(display("Failed to convert struct from datatypes"))] ConvertDatatypes { location: Location, source: datatypes::error::Error, }, - #[snafu(display("Invalid raw region request, err: {}, location: {}", err, location))] + #[snafu(display("Invalid raw region request, err: {}", err))] InvalidRawRegionRequest { err: String, location: Location }, - #[snafu(display( - "Invalid region request, region_id: {}, err: {}, location: {}", - region_id, - err, - location - ))] + #[snafu(display("Invalid region request, region_id: {}, err: {}", region_id, err))] InvalidRegionRequest { region_id: RegionId, err: String,