diff --git a/Cargo.lock b/Cargo.lock index cfb73999c47b..46597f9e3df8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -225,7 +225,7 @@ dependencies = [ "greptime-proto", "paste", "prost 0.12.4", - "snafu", + "snafu 0.8.2", "tonic-build 0.9.2", ] @@ -715,7 +715,7 @@ dependencies = [ "digest", "notify", "sha1", - "snafu", + "snafu 0.8.2", "sql", "tokio", ] @@ -1279,7 +1279,7 @@ dependencies = [ "prometheus", "serde_json", "session", - "snafu", + "snafu 0.8.2", "sql", "store-api", "table", @@ -1555,7 +1555,7 @@ dependencies = [ "prost 0.12.4", "rand", "serde_json", - "snafu", + "snafu 0.8.2", "substrait 0.17.1", "substrait 0.7.2", "tokio", @@ -1638,7 +1638,7 @@ dependencies = [ "serde_json", "servers", "session", - "snafu", + "snafu 0.8.2", "store-api", "substrait 0.7.2", "table", @@ -1693,7 +1693,7 @@ dependencies = [ "common-macro", "paste", "serde", - "snafu", + "snafu 0.8.2", "toml 0.8.12", "zeroize", ] @@ -1705,7 +1705,7 @@ dependencies = [ "chrono", "common-error", "common-macro", - "snafu", + "snafu 0.8.2", "tokio", ] @@ -1744,7 +1744,7 @@ dependencies = [ "paste", "regex", "serde", - "snafu", + "snafu 0.8.2", "strum 0.25.0", "tokio", "tokio-util", @@ -1761,14 +1761,14 @@ dependencies = [ "rust_decimal", "serde", "serde_json", - "snafu", + "snafu 0.8.2", ] [[package]] name = "common-error" version = "0.7.2" dependencies = [ - "snafu", + "snafu 0.8.2", "strum 0.25.0", ] @@ -1783,7 +1783,7 @@ dependencies = [ "common-macro", "common-query", "session", - "snafu", + "snafu 0.8.2", "sql", ] @@ -1814,7 +1814,7 @@ dependencies = [ "serde", "serde_json", "session", - "snafu", + "snafu 0.8.2", "statrs", "store-api", "table", @@ -1857,7 +1857,7 @@ dependencies = [ "lazy_static", "prost 0.12.4", "rand", - "snafu", + "snafu 0.8.2", "tokio", "tonic 0.11.0", "tower", @@ -1876,7 +1876,7 @@ dependencies = [ "common-time", "datatypes", "paste", - "snafu", + "snafu 0.8.2", "table", ] @@ -1889,7 +1889,7 @@ dependencies = [ "datatypes", "proc-macro2", "quote", - "snafu", + "snafu 0.8.2", "static_assertions", "syn 1.0.109", "syn 2.0.61", @@ -1901,7 +1901,7 @@ version = "0.7.2" dependencies = [ "common-error", "common-macro", - "snafu", + "snafu 0.8.2", "tempfile", "tikv-jemalloc-ctl", "tikv-jemalloc-sys", @@ -1951,7 +1951,7 @@ dependencies = [ "serde_json", "serde_with", "session", - "snafu", + "snafu 0.8.2", "store-api", "strum 0.25.0", "table", @@ -1985,7 +1985,7 @@ dependencies = [ "serde", "serde_json", "smallvec", - "snafu", + "snafu 0.8.2", "tokio", "uuid", ] @@ -2014,7 +2014,7 @@ dependencies = [ "datafusion-expr", "datatypes", "serde", - "snafu", + "snafu 0.8.2", "sqlparser 0.44.0 (git+https://github.com/GreptimeTeam/sqlparser-rs.git?rev=c919990bf62ad38d2b0c0a3bc90b26ad919d51b0)", "sqlparser_derive 0.1.1", "statrs", @@ -2036,7 +2036,7 @@ dependencies = [ "pin-project", "serde", "serde_json", - "snafu", + "snafu 0.8.2", "tokio", ] @@ -2052,7 +2052,7 @@ dependencies = [ "once_cell", "paste", "prometheus", - "snafu", + "snafu 0.8.2", "tokio", "tokio-metrics", "tokio-metrics-collector", @@ -2112,7 +2112,7 @@ dependencies = [ "rand", "serde", "serde_json", - "snafu", + "snafu 0.8.2", ] [[package]] @@ -2138,7 +2138,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "snafu", + "snafu 0.8.2", "tokio", "toml 0.8.12", ] @@ -2898,7 +2898,7 @@ dependencies = [ "serde", "servers", "session", - "snafu", + "snafu 0.8.2", "store-api", "substrait 0.7.2", "table", @@ -2928,7 +2928,7 @@ dependencies = [ "paste", "serde", "serde_json", - "snafu", + "snafu 0.8.2", ] [[package]] @@ -3430,7 +3430,7 @@ dependencies = [ "object-store", "serde", "serde_json", - "snafu", + "snafu 0.8.2", "store-api", "table", "tokio", @@ -3535,7 +3535,7 @@ dependencies = [ "servers", "session", "smallvec", - "snafu", + "snafu 0.8.2", "strum 0.25.0", "substrait 0.7.2", "table", @@ -3618,7 +3618,7 @@ dependencies = [ "serde", "servers", "session", - "snafu", + "snafu 0.8.2", "sql", "sqlparser 0.44.0 (git+https://github.com/GreptimeTeam/sqlparser-rs.git?rev=c919990bf62ad38d2b0c0a3bc90b26ad919d51b0)", "store-api", @@ -4411,7 +4411,7 @@ dependencies = [ "rand", "regex", "regex-automata 0.4.6", - "snafu", + "snafu 0.8.2", "tempfile", "tokio", "tokio-util", @@ -4484,7 +4484,7 @@ dependencies = [ "bytes", "nom", "smallvec", - "snafu", + "snafu 0.7.5", ] [[package]] @@ -4986,7 +4986,7 @@ dependencies = [ "rskafka", "serde", "serde_json", - "snafu", + "snafu 0.8.2", "store-api", "tokio", "uuid", @@ -5260,7 +5260,7 @@ dependencies = [ "meta-srv", "rand", "serde", - "snafu", + "snafu 0.8.2", "tokio", "tokio-stream", "tonic 0.11.0", @@ -5312,7 +5312,7 @@ dependencies = [ "serde_json", "servers", "session", - "snafu", + "snafu 0.8.2", "store-api", "table", "tokio", @@ -5368,7 +5368,7 @@ dependencies = [ "object-store", "prometheus", "serde_json", - "snafu", + "snafu 0.8.2", "store-api", "tokio", ] @@ -5468,7 +5468,7 @@ dependencies = [ "serde_json", "serde_with", "smallvec", - "snafu", + "snafu 0.8.2", "store-api", "strum 0.25.0", "table", @@ -6069,7 +6069,7 @@ dependencies = [ "itertools 0.12.1", "parking_lot 0.12.2", "percent-encoding", - "snafu", + "snafu 0.7.5", "tokio", "tracing", "url", @@ -6320,7 +6320,7 @@ dependencies = [ "serde_json", "servers", "session", - "snafu", + "snafu 0.8.2", "sql", "sqlparser 0.44.0 (git+https://github.com/GreptimeTeam/sqlparser-rs.git?rev=c919990bf62ad38d2b0c0a3bc90b26ad919d51b0)", "store-api", @@ -6350,7 +6350,7 @@ dependencies = [ "lazy_static", "paste", "prost 0.11.9", - "snafu", + "snafu 0.7.5", "tokio", "zigzag", "zstd 0.12.4", @@ -6574,7 +6574,7 @@ dependencies = [ "itertools 0.10.5", "serde", "serde_json", - "snafu", + "snafu 0.8.2", "sql", "sqlparser 0.44.0 (git+https://github.com/GreptimeTeam/sqlparser-rs.git?rev=c919990bf62ad38d2b0c0a3bc90b26ad919d51b0)", "store-api", @@ -6913,7 +6913,7 @@ dependencies = [ "datanode", "frontend", "meta-srv", - "snafu", + "snafu 0.8.2", ] [[package]] @@ -7200,7 +7200,7 @@ dependencies = [ "prost 0.12.4", "query", "session", - "snafu", + "snafu 0.8.2", "table", "tokio", ] @@ -7398,7 +7398,7 @@ dependencies = [ "pin-project", "serde", "serde_json", - "snafu", + "snafu 0.8.2", "tokio", "tokio-util", ] @@ -7549,7 +7549,7 @@ dependencies = [ "rand", "regex", "session", - "snafu", + "snafu 0.8.2", "sql", "statrs", "stats-cli", @@ -8909,7 +8909,7 @@ dependencies = [ "serde", "servers", "session", - "snafu", + "snafu 0.8.2", "sql", "table", "tokio", @@ -9212,7 +9212,7 @@ dependencies = [ "serde", "serde_json", "session", - "snafu", + "snafu 0.8.2", "snap", "sql", "strum 0.25.0", @@ -9247,7 +9247,7 @@ dependencies = [ "common-telemetry", "common-time", "derive_builder 0.12.0", - "snafu", + "snafu 0.8.2", "sql", ] @@ -9406,7 +9406,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4de37ad025c587a29e8f3f5605c00f70b98715ef90b9061a815b9e59e9042d6" dependencies = [ "doc-comment", - "snafu-derive", + "snafu-derive 0.7.5", +] + +[[package]] +name = "snafu" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75976f4748ab44f6e5332102be424e7c2dc18daeaf7e725f2040c3ebb133512e" +dependencies = [ + "snafu-derive 0.8.2", ] [[package]] @@ -9421,6 +9430,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "snafu-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4b19911debfb8c2fb1107bc6cb2d61868aaf53a988449213959bb1b5b1ed95f" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.61", +] + [[package]] name = "snap" version = "1.1.1" @@ -9515,7 +9536,7 @@ dependencies = [ "itertools 0.10.5", "lazy_static", "regex", - "snafu", + "snafu 0.8.2", "sqlparser 0.44.0 (git+https://github.com/GreptimeTeam/sqlparser-rs.git?rev=c919990bf62ad38d2b0c0a3bc90b26ad919d51b0)", "sqlparser_derive 0.1.1", "table", @@ -9784,7 +9805,7 @@ dependencies = [ "futures", "serde", "serde_json", - "snafu", + "snafu 0.8.2", "strum 0.25.0", "tokio", ] @@ -9950,7 +9971,7 @@ dependencies = [ "promql", "prost 0.12.4", "session", - "snafu", + "snafu 0.8.2", "substrait 0.17.1", "tokio", ] @@ -10151,7 +10172,7 @@ dependencies = [ "paste", "serde", "serde_json", - "snafu", + "snafu 0.8.2", "store-api", "tokio", "tokio-util", @@ -10255,7 +10276,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "snafu", + "snafu 0.8.2", "sql", "sqlparser 0.44.0 (git+https://github.com/GreptimeTeam/sqlparser-rs.git?rev=c919990bf62ad38d2b0c0a3bc90b26ad919d51b0)", "sqlx", @@ -10317,7 +10338,7 @@ dependencies = [ "serde_json", "servers", "session", - "snafu", + "snafu 0.8.2", "sql", "sqlx", "store-api", diff --git a/Cargo.toml b/Cargo.toml index d4e0568cd87b..1521b7930b4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -154,7 +154,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["float_roundtrip"] } serde_with = "3" smallvec = { version = "1", features = ["serde"] } -snafu = "0.7" +snafu = "0.8" sysinfo = "0.30" # on branch v0.44.x sqlparser = { git = "https://github.com/GreptimeTeam/sqlparser-rs.git", rev = "c919990bf62ad38d2b0c0a3bc90b26ad919d51b0", features = [ diff --git a/src/api/src/error.rs b/src/api/src/error.rs index 4763b1c3dd6e..b8bd517188ed 100644 --- a/src/api/src/error.rs +++ b/src/api/src/error.rs @@ -30,6 +30,7 @@ pub enum Error { #[snafu(display("Unknown proto column datatype: {}", datatype))] UnknownColumnDataType { datatype: i32, + #[snafu(implicit)] location: Location, #[snafu(source)] error: prost::DecodeError, @@ -38,12 +39,14 @@ pub enum Error { #[snafu(display("Failed to create column datatype from {:?}", from))] IntoColumnDataType { from: ConcreteDataType, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to convert column default constraint, column: {}", column))] ConvertColumnDefaultConstraint { column: String, + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, @@ -51,6 +54,7 @@ pub enum Error { #[snafu(display("Invalid column default constraint, column: {}", column))] InvalidColumnDefaultConstraint { column: String, + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, diff --git a/src/auth/src/error.rs b/src/auth/src/error.rs index bb9f37e83b60..ab5a3227e07f 100644 --- a/src/auth/src/error.rs +++ b/src/auth/src/error.rs @@ -34,11 +34,13 @@ pub enum Error { Io { #[snafu(source)] error: std::io::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Auth failed"))] AuthBackend { + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -72,7 +74,10 @@ pub enum Error { }, #[snafu(display("User is not authorized to perform this action"))] - PermissionDenied { location: Location }, + PermissionDenied { + #[snafu(implicit)] + location: Location, + }, } impl ErrorExt for Error { diff --git a/src/catalog/src/error.rs b/src/catalog/src/error.rs index 20cac754b9f0..2d3a9083088e 100644 --- a/src/catalog/src/error.rs +++ b/src/catalog/src/error.rs @@ -30,12 +30,14 @@ use tokio::task::JoinError; pub enum Error { #[snafu(display("Failed to list catalogs"))] ListCatalogs { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Failed to list {}'s schemas", catalog))] ListSchemas { + #[snafu(implicit)] location: Location, catalog: String, source: BoxedError, @@ -43,6 +45,7 @@ pub enum Error { #[snafu(display("Failed to list {}.{}'s tables", catalog, schema))] ListTables { + #[snafu(implicit)] location: Location, catalog: String, schema: String, @@ -51,23 +54,27 @@ pub enum Error { #[snafu(display("Failed to list nodes in cluster: {source}"))] ListNodes { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Failed to re-compile script due to internal error"))] CompileScriptInternal { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Failed to open system catalog table"))] OpenSystemCatalog { + #[snafu(implicit)] location: Location, source: table::error::Error, }, #[snafu(display("Failed to create system catalog table"))] CreateSystemCatalog { + #[snafu(implicit)] location: Location, source: table::error::Error, }, @@ -75,12 +82,17 @@ pub enum Error { #[snafu(display("Failed to create table, table info: {}", table_info))] CreateTable { table_info: String, + #[snafu(implicit)] location: Location, source: table::error::Error, }, #[snafu(display("System catalog is not valid: {}", msg))] - SystemCatalog { msg: String, location: Location }, + SystemCatalog { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "System catalog table type mismatch, expected: binary, found: {:?}", @@ -88,34 +100,42 @@ pub enum Error { ))] SystemCatalogTypeMismatch { data_type: ConcreteDataType, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid system catalog entry type: {:?}", entry_type))] InvalidEntryType { entry_type: Option, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid system catalog key: {:?}", key))] InvalidKey { key: Option, + #[snafu(implicit)] location: Location, }, #[snafu(display("Catalog value is not present"))] - EmptyValue { location: Location }, + EmptyValue { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to deserialize value"))] ValueDeserialize { #[snafu(source)] error: serde_json::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Table engine not found: {}", engine_name))] TableEngineNotFound { engine_name: String, + #[snafu(implicit)] location: Location, source: table::error::Error, }, @@ -123,6 +143,7 @@ pub enum Error { #[snafu(display("Cannot find catalog by name: {}", catalog_name))] CatalogNotFound { catalog_name: String, + #[snafu(implicit)] location: Location, }, @@ -130,30 +151,49 @@ pub enum Error { SchemaNotFound { catalog: String, schema: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Table `{}` already exists", table))] - TableExists { table: String, location: Location }, + TableExists { + table: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Table not found: {}", table))] - TableNotExist { table: String, location: Location }, + TableNotExist { + table: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Schema {} already exists", schema))] - SchemaExists { schema: String, location: Location }, + SchemaExists { + schema: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Operation {} not implemented yet", operation))] Unimplemented { operation: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Operation {} not supported", op))] - NotSupported { op: String, location: Location }, + NotSupported { + op: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to open table {table_id}"))] OpenTable { table_id: TableId, + #[snafu(implicit)] location: Location, source: table::error::Error, }, @@ -167,6 +207,7 @@ pub enum Error { #[snafu(display("Table not found while opening table, table info: {}", table_info))] TableNotFound { table_info: String, + #[snafu(implicit)] location: Location, }, @@ -178,57 +219,69 @@ pub enum Error { #[snafu(display("Failed to read system catalog table records"))] ReadSystemCatalog { + #[snafu(implicit)] location: Location, source: common_recordbatch::error::Error, }, #[snafu(display("Failed to create recordbatch"))] CreateRecordBatch { + #[snafu(implicit)] location: Location, source: common_recordbatch::error::Error, }, #[snafu(display("Failed to insert table creation record to system catalog"))] InsertCatalogRecord { + #[snafu(implicit)] location: Location, source: table::error::Error, }, #[snafu(display("Failed to scan system catalog table"))] SystemCatalogTableScan { + #[snafu(implicit)] location: Location, source: table::error::Error, }, #[snafu(display("Internal error"))] Internal { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Failed to upgrade weak catalog manager reference"))] - UpgradeWeakCatalogManagerRef { location: Location }, + UpgradeWeakCatalogManagerRef { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to execute system catalog table scan"))] SystemCatalogTableScanExec { + #[snafu(implicit)] location: Location, source: common_query::error::Error, }, #[snafu(display("Cannot parse catalog value"))] InvalidCatalogValue { + #[snafu(implicit)] location: Location, source: common_catalog::error::Error, }, #[snafu(display("Failed to perform metasrv operation"))] Metasrv { + #[snafu(implicit)] location: Location, source: meta_client::error::Error, }, #[snafu(display("Invalid table info in catalog"))] InvalidTableInfoInCatalog { + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, @@ -240,26 +293,37 @@ pub enum Error { Datafusion { #[snafu(source)] error: DataFusionError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Table schema mismatch"))] TableSchemaMismatch { + #[snafu(implicit)] location: Location, source: table::error::Error, }, #[snafu(display("A generic error has occurred, msg: {}", msg))] - Generic { msg: String, location: Location }, + Generic { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Table metadata manager error"))] TableMetadataManager { source: common_meta::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Get null from table cache, key: {}", key))] - TableCacheNotGet { key: String, location: Location }, + TableCacheNotGet { + key: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to get table cache, err: {}", err_msg))] GetTableCache { err_msg: String }, diff --git a/src/client/src/error.rs b/src/client/src/error.rs index aa0b66558fd2..5add743ce31d 100644 --- a/src/client/src/error.rs +++ b/src/client/src/error.rs @@ -26,7 +26,11 @@ use tonic::{Code, Status}; #[stack_trace_debug] pub enum Error { #[snafu(display("Illegal Flight messages, reason: {}", reason))] - IllegalFlightMessages { reason: String, location: Location }, + IllegalFlightMessages { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to do Flight get, code: {}", tonic_code))] FlightGet { @@ -37,31 +41,43 @@ pub enum Error { #[snafu(display("Failure occurs during handling request"))] HandleRequest { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Failed to convert FlightData"))] ConvertFlightData { + #[snafu(implicit)] location: Location, 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, location: Location }, + IllegalGrpcClientState { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Missing required field in protobuf, field: {}", field))] - MissingField { field: String, location: Location }, + MissingField { + field: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to create gRPC channel, peer address: {}", addr))] CreateChannel { addr: String, + #[snafu(implicit)] location: Location, source: common_grpc::error::Error, }, @@ -77,7 +93,11 @@ pub enum Error { IllegalDatabaseResponse { err_msg: String }, #[snafu(display("Failed to send request with streaming: {}", err_msg))] - ClientStreaming { err_msg: String, location: Location }, + ClientStreaming { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, } pub type Result = std::result::Result; diff --git a/src/cmd/src/cli/upgrade.rs b/src/cmd/src/cli/upgrade.rs index a36333c9c483..ca362c8db4d9 100644 --- a/src/cmd/src/cli/upgrade.rs +++ b/src/cmd/src/cli/upgrade.rs @@ -565,11 +565,16 @@ mod v1_helper { #[snafu(visibility(pub))] pub enum Error { #[snafu(display("Invalid catalog info: {}", key))] - InvalidCatalog { key: String, location: Location }, + InvalidCatalog { + key: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to deserialize catalog entry value: {}", raw))] DeserializeCatalogEntryValue { raw: String, + #[snafu(implicit)] location: Location, source: serde_json::error::Error, }, diff --git a/src/cmd/src/error.rs b/src/cmd/src/error.rs index d24f00f5be44..15d0dc9b0d98 100644 --- a/src/cmd/src/error.rs +++ b/src/cmd/src/error.rs @@ -27,97 +27,120 @@ use snafu::{Location, Snafu}; pub enum Error { #[snafu(display("Failed to create default catalog and schema"))] InitMetadata { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to iter stream"))] IterStream { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to init DDL manager"))] InitDdlManager { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to init default timezone"))] InitTimezone { + #[snafu(implicit)] location: Location, source: common_time::error::Error, }, #[snafu(display("Failed to start procedure manager"))] StartProcedureManager { + #[snafu(implicit)] location: Location, source: common_procedure::error::Error, }, #[snafu(display("Failed to stop procedure manager"))] StopProcedureManager { + #[snafu(implicit)] location: Location, source: common_procedure::error::Error, }, #[snafu(display("Failed to start wal options allocator"))] StartWalOptionsAllocator { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to start datanode"))] StartDatanode { + #[snafu(implicit)] location: Location, source: datanode::error::Error, }, #[snafu(display("Failed to shutdown datanode"))] ShutdownDatanode { + #[snafu(implicit)] location: Location, source: datanode::error::Error, }, #[snafu(display("Failed to start frontend"))] StartFrontend { + #[snafu(implicit)] location: Location, source: frontend::error::Error, }, #[snafu(display("Failed to shutdown frontend"))] ShutdownFrontend { + #[snafu(implicit)] location: Location, source: frontend::error::Error, }, #[snafu(display("Failed to build meta server"))] BuildMetaServer { + #[snafu(implicit)] location: Location, source: meta_srv::error::Error, }, #[snafu(display("Failed to start meta server"))] StartMetaServer { + #[snafu(implicit)] location: Location, source: meta_srv::error::Error, }, #[snafu(display("Failed to shutdown meta server"))] ShutdownMetaServer { + #[snafu(implicit)] location: Location, source: meta_srv::error::Error, }, #[snafu(display("Missing config, msg: {}", msg))] - MissingConfig { msg: String, location: Location }, + MissingConfig { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Illegal config: {}", msg))] - IllegalConfig { msg: String, location: Location }, + IllegalConfig { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unsupported selector type: {}", selector_type))] UnsupportedSelectorType { selector_type: String, + #[snafu(implicit)] location: Location, source: meta_srv::error::Error, }, @@ -129,6 +152,7 @@ pub enum Error { ReplCreation { #[snafu(source)] error: ReadlineError, + #[snafu(implicit)] location: Location, }, @@ -136,23 +160,27 @@ pub enum Error { Readline { #[snafu(source)] error: ReadlineError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to collect RecordBatches"))] CollectRecordBatches { + #[snafu(implicit)] location: Location, source: common_recordbatch::error::Error, }, #[snafu(display("Failed to pretty print Recordbatches"))] PrettyPrintRecordBatches { + #[snafu(implicit)] location: Location, source: common_recordbatch::error::Error, }, #[snafu(display("Failed to start Meta client"))] StartMetaClient { + #[snafu(implicit)] location: Location, source: meta_client::error::Error, }, @@ -160,18 +188,21 @@ pub enum Error { #[snafu(display("Failed to parse SQL: {}", sql))] ParseSql { sql: String, + #[snafu(implicit)] location: Location, source: query::error::Error, }, #[snafu(display("Failed to plan statement"))] PlanStatement { + #[snafu(implicit)] location: Location, source: query::error::Error, }, #[snafu(display("Failed to encode logical plan in substrait"))] SubstraitEncodeLogicalPlan { + #[snafu(implicit)] location: Location, source: substrait::error::Error, }, @@ -180,11 +211,13 @@ pub enum Error { LoadLayeredConfig { #[snafu(source)] error: ConfigError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to start catalog manager"))] StartCatalogManager { + #[snafu(implicit)] location: Location, source: catalog::error::Error, }, @@ -194,6 +227,7 @@ pub enum Error { etcd_addr: String, #[snafu(source)] error: etcd_client::Error, + #[snafu(implicit)] location: Location, }, @@ -201,6 +235,7 @@ pub enum Error { ConnectServer { addr: String, source: client::error::Error, + #[snafu(implicit)] location: Location, }, @@ -208,6 +243,7 @@ pub enum Error { SerdeJson { #[snafu(source)] error: serde_json::error::Error, + #[snafu(implicit)] location: Location, }, @@ -216,17 +252,25 @@ pub enum Error { reason: String, #[snafu(source)] error: reqwest::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Expect data from output, but got another thing"))] - NotDataFromOutput { location: Location }, + NotDataFromOutput { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Empty result from output"))] - EmptyResult { location: Location }, + EmptyResult { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to manipulate file"))] FileIo { + #[snafu(implicit)] location: Location, #[snafu(source)] error: std::io::Error, @@ -234,6 +278,7 @@ pub enum Error { #[snafu(display("Invalid database name: {}", database))] InvalidDatabaseName { + #[snafu(implicit)] location: Location, database: String, }, @@ -248,11 +293,13 @@ pub enum Error { #[snafu(display("Other error"))] Other { source: BoxedError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to build runtime"))] BuildRuntime { + #[snafu(implicit)] location: Location, source: common_runtime::error::Error, }, diff --git a/src/common/base/src/buffer.rs b/src/common/base/src/buffer.rs index 1eb696e6671a..bce39842e1f5 100644 --- a/src/common/base/src/buffer.rs +++ b/src/common/base/src/buffer.rs @@ -33,16 +33,21 @@ pub enum Error { Overflow { src_len: usize, dst_len: usize, + #[snafu(implicit)] location: Location, }, #[snafu(display("Buffer underflow"))] - Underflow { location: Location }, + Underflow { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("IO operation reach EOF"))] Eof { #[snafu(source)] error: std::io::Error, + #[snafu(implicit)] location: Location, }, } diff --git a/src/common/catalog/src/error.rs b/src/common/catalog/src/error.rs index 46166b1ccee5..df6e4a4078f5 100644 --- a/src/common/catalog/src/error.rs +++ b/src/common/catalog/src/error.rs @@ -26,6 +26,7 @@ pub enum Error { #[snafu(display("Invalid full table name: {}", table_name))] InvalidFullTableName { table_name: String, + #[snafu(implicit)] location: Location, }, } diff --git a/src/common/datasource/src/error.rs b/src/common/datasource/src/error.rs index fc2b81ecfc53..527c20ff863e 100644 --- a/src/common/datasource/src/error.rs +++ b/src/common/datasource/src/error.rs @@ -29,27 +29,38 @@ pub enum Error { #[snafu(display("Unsupported compression type: {}", compression_type))] UnsupportedCompressionType { compression_type: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unsupported backend protocol: {}, url: {}", protocol, url))] UnsupportedBackendProtocol { protocol: String, + #[snafu(implicit)] location: Location, url: String, }, #[snafu(display("Unsupported format protocol: {}", format))] - UnsupportedFormat { format: String, location: Location }, + UnsupportedFormat { + format: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("empty host: {}", url))] - EmptyHostPath { url: String, location: Location }, + EmptyHostPath { + url: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid url: {}", url))] InvalidUrl { url: String, #[snafu(source)] error: ParseError, + #[snafu(implicit)] location: Location, }, @@ -57,11 +68,13 @@ pub enum Error { BuildBackend { #[snafu(source)] error: object_store::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to build orc reader"))] OrcReader { + #[snafu(implicit)] location: Location, #[snafu(source)] error: orc_rust::error::Error, @@ -70,6 +83,7 @@ pub enum Error { #[snafu(display("Failed to read object from path: {}", path))] ReadObject { path: String, + #[snafu(implicit)] location: Location, #[snafu(source)] error: object_store::Error, @@ -78,6 +92,7 @@ pub enum Error { #[snafu(display("Failed to write object to path: {}", path))] WriteObject { path: String, + #[snafu(implicit)] location: Location, #[snafu(source)] error: object_store::Error, @@ -87,11 +102,13 @@ pub enum Error { AsyncWrite { #[snafu(source)] error: std::io::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to write record batch"))] WriteRecordBatch { + #[snafu(implicit)] location: Location, #[snafu(source)] error: ArrowError, @@ -99,6 +116,7 @@ pub enum Error { #[snafu(display("Failed to encode record batch"))] EncodeRecordBatch { + #[snafu(implicit)] location: Location, #[snafu(source)] error: ParquetError, @@ -106,6 +124,7 @@ pub enum Error { #[snafu(display("Failed to read record batch"))] ReadRecordBatch { + #[snafu(implicit)] location: Location, #[snafu(source)] error: datafusion::error::DataFusionError, @@ -113,6 +132,7 @@ pub enum Error { #[snafu(display("Failed to read parquet"))] ReadParquetSnafu { + #[snafu(implicit)] location: Location, #[snafu(source)] error: datafusion::parquet::errors::ParquetError, @@ -120,6 +140,7 @@ pub enum Error { #[snafu(display("Failed to convert parquet to schema"))] ParquetToSchema { + #[snafu(implicit)] location: Location, #[snafu(source)] error: datafusion::parquet::errors::ParquetError, @@ -127,6 +148,7 @@ pub enum Error { #[snafu(display("Failed to infer schema from file"))] InferSchema { + #[snafu(implicit)] location: Location, #[snafu(source)] error: arrow_schema::ArrowError, @@ -135,16 +157,22 @@ pub enum Error { #[snafu(display("Failed to list object in path: {}", path))] ListObjects { path: String, + #[snafu(implicit)] location: Location, #[snafu(source)] error: object_store::Error, }, #[snafu(display("Invalid connection: {}", msg))] - InvalidConnection { msg: String, location: Location }, + InvalidConnection { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to join handle"))] JoinHandle { + #[snafu(implicit)] location: Location, #[snafu(source)] error: tokio::task::JoinError, @@ -154,6 +182,7 @@ pub enum Error { ParseFormat { key: &'static str, value: String, + #[snafu(implicit)] location: Location, }, @@ -161,15 +190,20 @@ pub enum Error { MergeSchema { #[snafu(source)] error: arrow_schema::ArrowError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Buffered writer closed"))] - BufferedWriterClosed { location: Location }, + BufferedWriterClosed { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to write parquet file, path: {}", path))] WriteParquet { path: String, + #[snafu(implicit)] location: Location, #[snafu(source)] error: parquet::errors::ParquetError, diff --git a/src/common/decimal/src/error.rs b/src/common/decimal/src/error.rs index e65beb6e99e6..c1b8dd67056b 100644 --- a/src/common/decimal/src/error.rs +++ b/src/common/decimal/src/error.rs @@ -25,6 +25,7 @@ pub enum Error { #[snafu(display("Decimal out of range, decimal value: {}", value))] BigDecimalOutOfRange { value: BigDecimal, + #[snafu(implicit)] location: Location, }, @@ -43,7 +44,11 @@ pub enum Error { }, #[snafu(display("Invalid precision or scale, resion: {}", reason))] - InvalidPrecisionOrScale { reason: String, location: Location }, + InvalidPrecisionOrScale { + reason: String, + #[snafu(implicit)] + location: Location, + }, } impl ErrorExt for Error { diff --git a/src/common/frontend/src/error.rs b/src/common/frontend/src/error.rs index d2bbc3dad5e1..7fc905dc6f3f 100644 --- a/src/common/frontend/src/error.rs +++ b/src/common/frontend/src/error.rs @@ -23,6 +23,7 @@ use snafu::{Location, Snafu}; pub enum Error { #[snafu(display("External error"))] External { + #[snafu(implicit)] location: Location, source: BoxedError, }, diff --git a/src/common/grpc-expr/src/error.rs b/src/common/grpc-expr/src/error.rs index 15a5a3ffc794..378473f22eaa 100644 --- a/src/common/grpc-expr/src/error.rs +++ b/src/common/grpc-expr/src/error.rs @@ -24,10 +24,15 @@ use snafu::{Location, Snafu}; #[stack_trace_debug] pub enum Error { #[snafu(display("Illegal delete request, reason: {reason}"))] - IllegalDeleteRequest { reason: String, location: Location }, + IllegalDeleteRequest { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Column datatype error"))] ColumnDataType { + #[snafu(implicit)] location: Location, source: api::error::Error, }, @@ -40,39 +45,63 @@ pub enum Error { DuplicatedTimestampColumn { exists: String, duplicated: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Duplicated column name in gRPC requests, name: {}", name,))] - DuplicatedColumnName { name: String, location: Location }, + DuplicatedColumnName { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Missing timestamp column, msg: {}", msg))] - MissingTimestampColumn { msg: String, location: Location }, + MissingTimestampColumn { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid column proto: {}", err_msg))] - InvalidColumnProto { err_msg: String, location: Location }, + InvalidColumnProto { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to create vector"))] CreateVector { + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, #[snafu(display("Missing required field in protobuf, field: {}", field))] - MissingField { field: String, location: Location }, + MissingField { + field: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid column proto definition, column: {}", column))] InvalidColumnDef { column: String, + #[snafu(implicit)] location: Location, source: api::error::Error, }, #[snafu(display("Unexpected values length, reason: {}", reason))] - UnexpectedValuesLength { reason: String, location: Location }, + UnexpectedValuesLength { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unknown location type: {}", location_type))] UnknownLocationType { location_type: i32, + #[snafu(implicit)] location: Location, }, } diff --git a/src/common/grpc/src/error.rs b/src/common/grpc/src/error.rs index e6ddab8c126c..d0ca7d970c62 100644 --- a/src/common/grpc/src/error.rs +++ b/src/common/grpc/src/error.rs @@ -33,6 +33,7 @@ pub enum Error { InvalidConfigFilePath { #[snafu(source)] error: io::Error, + #[snafu(implicit)] location: Location, }, @@ -46,6 +47,7 @@ pub enum Error { column_name: String, expected: String, actual: String, + #[snafu(implicit)] location: Location, }, @@ -53,30 +55,42 @@ pub enum Error { CreateChannel { #[snafu(source)] error: tonic::transport::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to create RecordBatch"))] CreateRecordBatch { + #[snafu(implicit)] location: Location, source: common_recordbatch::error::Error, }, #[snafu(display("Failed to convert Arrow type: {}", from))] - Conversion { from: String, location: Location }, + Conversion { + from: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to decode FlightData"))] DecodeFlightData { #[snafu(source)] error: api::DecodeError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid FlightData, reason: {}", reason))] - InvalidFlightData { reason: String, location: Location }, + InvalidFlightData { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to convert Arrow Schema"))] ConvertArrowSchema { + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, diff --git a/src/common/mem-prof/src/jemalloc/error.rs b/src/common/mem-prof/src/jemalloc/error.rs index a0e0f2ede068..76a93db09a58 100644 --- a/src/common/mem-prof/src/jemalloc/error.rs +++ b/src/common/mem-prof/src/jemalloc/error.rs @@ -34,7 +34,11 @@ pub enum Error { ProfilingNotEnabled, #[snafu(display("Failed to build temp file from given path: {:?}", path))] - BuildTempPath { path: PathBuf, location: Location }, + BuildTempPath { + path: PathBuf, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to open temp file: {}", path))] OpenTempFile { diff --git a/src/common/meta/src/error.rs b/src/common/meta/src/error.rs index 2ce68269eea2..02b80edc15fe 100644 --- a/src/common/meta/src/error.rs +++ b/src/common/meta/src/error.rs @@ -32,7 +32,10 @@ use crate::DatanodeId; #[stack_trace_debug] pub enum Error { #[snafu(display("Empty key is not allowed"))] - EmptyKey { location: Location }, + EmptyKey { + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Another procedure is operating the region: {} on peer: {}", @@ -40,17 +43,23 @@ pub enum Error { peer_id ))] RegionOperatingRace { + #[snafu(implicit)] location: Location, peer_id: DatanodeId, region_id: RegionId, }, #[snafu(display("Invalid result with a txn response: {}", err_msg))] - InvalidTxnResult { err_msg: String, location: Location }, + InvalidTxnResult { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid engine type: {}", engine_type))] InvalidEngineType { engine_type: String, + #[snafu(implicit)] location: Location, }, @@ -58,6 +67,7 @@ pub enum Error { ConnectEtcd { #[snafu(source)] error: etcd_client::Error, + #[snafu(implicit)] location: Location, }, @@ -65,6 +75,7 @@ pub enum Error { EtcdFailed { #[snafu(source)] error: etcd_client::Error, + #[snafu(implicit)] location: Location, }, @@ -73,50 +84,72 @@ pub enum Error { max_operations: usize, #[snafu(source)] error: etcd_client::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to get sequence: {}", err_msg))] - NextSequence { err_msg: String, location: Location }, + NextSequence { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Sequence out of range: {}, start={}, step={}", name, start, step))] SequenceOutOfRange { name: String, start: u64, step: u64, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unexpected sequence value: {}", err_msg))] - UnexpectedSequenceValue { err_msg: String, location: Location }, + UnexpectedSequenceValue { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Table info not found: {}", table))] - TableInfoNotFound { table: String, location: Location }, + TableInfoNotFound { + table: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to register procedure loader, type name: {}", type_name))] RegisterProcedureLoader { type_name: String, + #[snafu(implicit)] location: Location, source: common_procedure::error::Error, }, #[snafu(display("Failed to submit procedure"))] SubmitProcedure { + #[snafu(implicit)] location: Location, source: common_procedure::Error, }, #[snafu(display("Failed to query procedure"))] QueryProcedure { + #[snafu(implicit)] location: Location, source: common_procedure::Error, }, #[snafu(display("Procedure not found: {pid}"))] - ProcedureNotFound { location: Location, pid: String }, + ProcedureNotFound { + #[snafu(implicit)] + location: Location, + pid: String, + }, #[snafu(display("Failed to parse procedure id: {key}"))] ParseProcedureId { + #[snafu(implicit)] location: Location, key: String, #[snafu(source)] @@ -126,11 +159,13 @@ pub enum Error { #[snafu(display("Unsupported operation {}", operation))] Unsupported { operation: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to wait procedure done"))] WaitProcedure { + #[snafu(implicit)] location: Location, source: common_procedure::Error, }, @@ -141,28 +176,36 @@ pub enum Error { ProcedureOutput { procedure_id: String, err_msg: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to convert RawTableInfo into TableInfo"))] ConvertRawTableInfo { + #[snafu(implicit)] location: Location, source: datatypes::Error, }, #[snafu(display("Primary key '{key}' not found when creating region request"))] - PrimaryKeyNotFound { key: String, location: Location }, + PrimaryKeyNotFound { + key: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to build table meta for table: {}", table_name))] BuildTableMeta { table_name: String, #[snafu(source)] error: table::metadata::TableMetaBuilderError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Table occurs error"))] Table { + #[snafu(implicit)] location: Location, source: table::error::Error, }, @@ -170,11 +213,13 @@ pub enum Error { #[snafu(display("Failed to find table route for table id {}", table_id))] TableRouteNotFound { table_id: TableId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to decode protobuf"))] DecodeProto { + #[snafu(implicit)] location: Location, #[snafu(source)] error: prost::DecodeError, @@ -182,6 +227,7 @@ pub enum Error { #[snafu(display("Failed to encode object into json"))] EncodeJson { + #[snafu(implicit)] location: Location, #[snafu(source)] error: JsonError, @@ -189,21 +235,30 @@ pub enum Error { #[snafu(display("Failed to decode object from json"))] DecodeJson { + #[snafu(implicit)] location: Location, #[snafu(source)] error: JsonError, }, #[snafu(display("Payload not exist"))] - PayloadNotExist { location: Location }, + PayloadNotExist { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to send message: {err_msg}"))] - SendMessage { err_msg: String, location: Location }, + SendMessage { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to serde json"))] SerdeJson { #[snafu(source)] error: serde_json::error::Error, + #[snafu(implicit)] location: Location, }, @@ -211,55 +266,78 @@ pub enum Error { ParseOption { key: String, value: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Corrupted table route data, err: {}", err_msg))] - RouteInfoCorrupted { err_msg: String, location: Location }, + RouteInfoCorrupted { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Illegal state from server, code: {}, error: {}", code, err_msg))] IllegalServerState { code: i32, err_msg: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to convert alter table request"))] ConvertAlterTableRequest { source: common_grpc_expr::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid protobuf message: {err_msg}"))] - InvalidProtoMsg { err_msg: String, location: Location }, + InvalidProtoMsg { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unexpected: {err_msg}"))] - Unexpected { err_msg: String, location: Location }, + Unexpected { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Table already exists, table: {}", table_name))] TableAlreadyExists { table_name: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Flow already exists: {}", flow_name))] FlowAlreadyExists { flow_name: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Catalog already exists, catalog: {}", catalog))] - CatalogAlreadyExists { catalog: String, location: Location }, + CatalogAlreadyExists { + catalog: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Schema already exists, catalog:{}, schema: {}", catalog, schema))] SchemaAlreadyExists { catalog: String, schema: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to convert raw key to str"))] ConvertRawKey { + #[snafu(implicit)] location: Location, #[snafu(source)] error: Utf8Error, @@ -268,35 +346,54 @@ pub enum Error { #[snafu(display("Table not found: '{}'", table_name))] TableNotFound { table_name: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Flow not found: '{}'", flow_name))] FlowNotFound { flow_name: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Schema nod found, schema: {}", table_schema))] SchemaNotFound { table_schema: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to rename table, reason: {}", reason))] - RenameTable { reason: String, location: Location }, + RenameTable { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid table metadata, err: {}", err_msg))] - InvalidTableMetadata { err_msg: String, location: Location }, + InvalidTableMetadata { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to get kv cache, err: {}", err_msg))] GetKvCache { err_msg: String }, #[snafu(display("Get null from cache, key: {}", key))] - CacheNotGet { key: String, location: Location }, + CacheNotGet { + key: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Etcd txn error: {err_msg}"))] - EtcdTxnOpResponse { err_msg: String, location: Location }, + EtcdTxnOpResponse { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Failed to move region {} in table {}, err: {}", @@ -308,26 +405,33 @@ pub enum Error { table_id: TableId, region: RegionNumber, err_msg: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid catalog value"))] InvalidCatalogValue { source: common_catalog::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("External error"))] External { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Invalid heartbeat response"))] - InvalidHeartbeatResponse { location: Location }, + InvalidHeartbeatResponse { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to operate on datanode: {}", peer))] OperateDatanode { + #[snafu(implicit)] location: Location, peer: Peer, source: BoxedError, @@ -344,12 +448,14 @@ pub enum Error { wal_options: WalOptions, #[snafu(source)] error: serde_json::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid number of topics {}", num_topics))] InvalidNumTopics { num_topics: usize, + #[snafu(implicit)] location: Location, }, @@ -359,6 +465,7 @@ pub enum Error { ))] BuildKafkaClient { broker_endpoints: Vec, + #[snafu(implicit)] location: Location, #[snafu(source)] error: rskafka::client::error::Error, @@ -369,6 +476,7 @@ pub enum Error { #[snafu(display("Failed to build a Kafka controller client"))] BuildKafkaCtrlClient { + #[snafu(implicit)] location: Location, #[snafu(source)] error: rskafka::client::error::Error, @@ -382,6 +490,7 @@ pub enum Error { BuildKafkaPartitionClient { topic: String, partition: i32, + #[snafu(implicit)] location: Location, #[snafu(source)] error: rskafka::client::error::Error, @@ -390,6 +499,7 @@ pub enum Error { #[snafu(display("Failed to produce records to Kafka, topic: {}", topic))] ProduceRecord { topic: String, + #[snafu(implicit)] location: Location, #[snafu(source)] error: rskafka::client::error::Error, @@ -397,66 +507,112 @@ pub enum Error { #[snafu(display("Failed to create a Kafka wal topic"))] CreateKafkaWalTopic { + #[snafu(implicit)] location: Location, #[snafu(source)] error: rskafka::client::error::Error, }, #[snafu(display("The topic pool is empty"))] - EmptyTopicPool { location: Location }, + EmptyTopicPool { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unexpected table route type: {}", err_msg))] - UnexpectedLogicalRouteTable { location: Location, err_msg: String }, + UnexpectedLogicalRouteTable { + #[snafu(implicit)] + location: Location, + err_msg: String, + }, #[snafu(display("The tasks of {} cannot be empty", name))] - EmptyDdlTasks { name: String, location: Location }, + EmptyDdlTasks { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Metadata corruption: {}", err_msg))] - MetadataCorruption { err_msg: String, location: Location }, + MetadataCorruption { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Alter logical tables invalid arguments: {}", err_msg))] - AlterLogicalTablesInvalidArguments { err_msg: String, location: Location }, + AlterLogicalTablesInvalidArguments { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Create logical tables invalid arguments: {}", err_msg))] - CreateLogicalTablesInvalidArguments { err_msg: String, location: Location }, + CreateLogicalTablesInvalidArguments { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid node info key: {}", key))] - InvalidNodeInfoKey { key: String, location: Location }, + InvalidNodeInfoKey { + key: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to parse number: {}", err_msg))] ParseNum { err_msg: String, #[snafu(source)] error: std::num::ParseIntError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid role: {}", role))] - InvalidRole { role: i32, location: Location }, + InvalidRole { + role: i32, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Delimiter not found, key: {}", key))] - DelimiterNotFound { key: String, location: Location }, + DelimiterNotFound { + key: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid prefix: {}, key: {}", prefix, key))] MismatchPrefix { prefix: String, key: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to move values: {err_msg}"))] - MoveValues { err_msg: String, location: Location }, + MoveValues { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to parse {} from utf8", name))] FromUtf8 { name: String, #[snafu(source)] error: std::string::FromUtf8Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Value not exists"))] - ValueNotExist { location: Location }, + ValueNotExist { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to get cache"))] GetCache { source: Arc }, diff --git a/src/common/procedure/src/error.rs b/src/common/procedure/src/error.rs index 6c881db9b1a8..48084b263599 100644 --- a/src/common/procedure/src/error.rs +++ b/src/common/procedure/src/error.rs @@ -32,27 +32,37 @@ pub enum Error { External { source: BoxedError }, #[snafu(display("Loader {} is already registered", name))] - LoaderConflict { name: String, location: Location }, + LoaderConflict { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Procedure Manager is stopped"))] - ManagerNotStart { location: Location }, + ManagerNotStart { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to serialize to json"))] ToJson { #[snafu(source)] error: serde_json::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Procedure {} already exists", procedure_id))] DuplicateProcedure { procedure_id: ProcedureId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to put state, key: '{key}'"))] PutState { key: String, + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -67,6 +77,7 @@ pub enum Error { #[snafu(display("Failed to delete keys: '{keys}'"))] DeleteStates { keys: String, + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -74,6 +85,7 @@ pub enum Error { #[snafu(display("Failed to list state, path: '{path}'"))] ListState { path: String, + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -82,6 +94,7 @@ pub enum Error { FromJson { #[snafu(source)] error: serde_json::Error, + #[snafu(implicit)] location: Location, }, @@ -95,17 +108,23 @@ pub enum Error { WaitWatcher { #[snafu(source)] error: tokio::sync::watch::error::RecvError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to execute procedure"))] ProcedureExec { source: Arc, + #[snafu(implicit)] location: Location, }, #[snafu(display("Rollback Procedure recovered: {error}"))] - RollbackProcedureRecovered { error: String, location: Location }, + RollbackProcedureRecovered { + error: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Procedure retry exceeded max times, procedure_id: {}", procedure_id))] RetryTimesExceeded { @@ -131,12 +150,14 @@ pub enum Error { #[snafu(display("Failed to start the remove_outdated_meta method, error"))] StartRemoveOutdatedMetaTask { source: common_runtime::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to stop the remove_outdated_meta method, error"))] StopRemoveOutdatedMetaTask { source: common_runtime::error::Error, + #[snafu(implicit)] location: Location, }, @@ -144,11 +165,13 @@ pub enum Error { SubprocedureFailed { subprocedure_id: ProcedureId, source: Arc, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to parse segment key: {key}"))] ParseSegmentKey { + #[snafu(implicit)] location: Location, key: String, #[snafu(source)] @@ -156,10 +179,17 @@ pub enum Error { }, #[snafu(display("Unexpected: {err_msg}"))] - Unexpected { location: Location, err_msg: String }, + Unexpected { + #[snafu(implicit)] + location: Location, + err_msg: String, + }, #[snafu(display("Not support to rollback the procedure"))] - RollbackNotSupported { location: Location }, + RollbackNotSupported { + #[snafu(implicit)] + location: Location, + }, } pub type Result = std::result::Result; diff --git a/src/common/query/src/error.rs b/src/common/query/src/error.rs index 758ec214b6a1..6756c58a8449 100644 --- a/src/common/query/src/error.rs +++ b/src/common/query/src/error.rs @@ -35,11 +35,13 @@ pub enum Error { PyUdf { // TODO(discord9): find a way that prevent circle depend(query<-script<-query) and can use script's error type msg: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to create temporary recordbatch when eval Python UDF"))] UdfTempRecordBatch { + #[snafu(implicit)] location: Location, source: RecordbatchError, }, @@ -48,6 +50,7 @@ pub enum Error { ExecuteFunction { #[snafu(source)] error: DataFusionError, + #[snafu(implicit)] location: Location, }, @@ -55,6 +58,7 @@ pub enum Error { UnsupportedInputDataType { function: String, datatypes: Vec, + #[snafu(implicit)] location: Location, }, @@ -62,23 +66,27 @@ pub enum Error { GenerateFunction { #[snafu(source)] error: StatsError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to cast scalar value into vector"))] FromScalarValue { + #[snafu(implicit)] location: Location, source: DataTypeError, }, #[snafu(display("Failed to cast arrow array into vector"))] FromArrowArray { + #[snafu(implicit)] location: Location, source: DataTypeError, }, #[snafu(display("Failed to cast arrow array into vector: {:?}", data_type))] IntoVector { + #[snafu(implicit)] location: Location, source: DataTypeError, data_type: ArrowDatatype, @@ -91,10 +99,15 @@ pub enum Error { DowncastVector { err_msg: String }, #[snafu(display("Bad accumulator implementation: {}", err_msg))] - BadAccumulatorImpl { err_msg: String, location: Location }, + BadAccumulatorImpl { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid input type: {}", err_msg))] InvalidInputType { + #[snafu(implicit)] location: Location, source: DataTypeError, err_msg: String, @@ -103,35 +116,48 @@ pub enum Error { #[snafu(display( "Illegal input_types status, check if DataFusion has changed its UDAF execution logic" ))] - InvalidInputState { location: Location }, + InvalidInputState { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("unexpected: not constant column"))] - InvalidInputCol { location: Location }, + InvalidInputCol { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Not expected to run ExecutionPlan more than once"))] - ExecuteRepeatedly { location: Location }, + ExecuteRepeatedly { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("General DataFusion error"))] GeneralDataFusion { #[snafu(source)] error: DataFusionError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to convert DataFusion's recordbatch stream"))] ConvertDfRecordBatchStream { + #[snafu(implicit)] location: Location, source: common_recordbatch::error::Error, }, #[snafu(display("Failed to convert arrow schema"))] ConvertArrowSchema { + #[snafu(implicit)] location: Location, source: DataTypeError, }, #[snafu(display("Failed to execute physical plan"))] ExecutePhysicalPlan { + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -141,6 +167,7 @@ pub enum Error { #[snafu(source)] error: ArrowError, typ: arrow::datatypes::DataType, + #[snafu(implicit)] location: Location, }, @@ -148,53 +175,76 @@ pub enum Error { ArrowCompute { #[snafu(source)] error: ArrowError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Query engine fail to cast value"))] ToScalarValue { + #[snafu(implicit)] location: Location, source: DataTypeError, }, #[snafu(display("Failed to get scalar vector"))] GetScalarVector { + #[snafu(implicit)] location: Location, source: DataTypeError, }, #[snafu(display("Failed to execute function: {source}"))] Execute { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Failed to join thread"))] - ThreadJoin { location: Location }, + ThreadJoin { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to do table mutation"))] TableMutation { source: BoxedError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to do procedure task"))] ProcedureService { source: BoxedError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Missing TableMutationHandler, not expected"))] - MissingTableMutationHandler { location: Location }, + MissingTableMutationHandler { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Missing ProcedureServiceHandler, not expected"))] - MissingProcedureServiceHandler { location: Location }, + MissingProcedureServiceHandler { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid function args: {}", err_msg))] - InvalidFuncArgs { err_msg: String, location: Location }, + InvalidFuncArgs { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Permission denied: {}", err_msg))] - PermissionDenied { err_msg: String, location: Location }, + PermissionDenied { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, } pub type Result = std::result::Result; diff --git a/src/common/recordbatch/src/error.rs b/src/common/recordbatch/src/error.rs index b22c0f488d74..745c2280de7b 100644 --- a/src/common/recordbatch/src/error.rs +++ b/src/common/recordbatch/src/error.rs @@ -32,27 +32,35 @@ pub enum Error { NewDfRecordBatch { #[snafu(source)] error: datatypes::arrow::error::ArrowError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Data types error"))] DataTypes { + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, #[snafu(display("External error"))] External { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Failed to create RecordBatches, reason: {}", reason))] - CreateRecordBatches { reason: String, location: Location }, + CreateRecordBatches { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to convert Arrow schema"))] SchemaConversion { source: datatypes::error::Error, + #[snafu(implicit)] location: Location, }, @@ -60,6 +68,7 @@ pub enum Error { PollStream { #[snafu(source)] error: datafusion::error::DataFusionError, + #[snafu(implicit)] location: Location, }, @@ -67,6 +76,7 @@ pub enum Error { Format { #[snafu(source)] error: datatypes::arrow::error::ArrowError, + #[snafu(implicit)] location: Location, }, @@ -75,6 +85,7 @@ pub enum Error { v: ScalarValue, #[snafu(source)] error: datafusion_common::DataFusionError, + #[snafu(implicit)] location: Location, }, @@ -86,6 +97,7 @@ pub enum Error { ProjectArrowRecordBatch { #[snafu(source)] error: datatypes::arrow::error::ArrowError, + #[snafu(implicit)] location: Location, schema: datatypes::schema::SchemaRef, projection: Vec, @@ -95,6 +107,7 @@ pub enum Error { ColumnNotExists { column_name: String, table_name: String, + #[snafu(implicit)] location: Location, }, @@ -106,6 +119,7 @@ pub enum Error { CastVector { from_type: ConcreteDataType, to_type: ConcreteDataType, + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, @@ -114,11 +128,16 @@ pub enum Error { ArrowCompute { #[snafu(source)] error: datatypes::arrow::error::ArrowError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unsupported operation: {}", reason))] - UnsupportedOperation { reason: String, location: Location }, + UnsupportedOperation { + reason: String, + #[snafu(implicit)] + location: Location, + }, } impl ErrorExt for Error { diff --git a/src/common/runtime/src/error.rs b/src/common/runtime/src/error.rs index 828306f76bc8..4c553bbcd5e2 100644 --- a/src/common/runtime/src/error.rs +++ b/src/common/runtime/src/error.rs @@ -29,17 +29,23 @@ pub enum Error { BuildRuntime { #[snafu(source)] error: std::io::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Repeated task {} is already started", name))] - IllegalState { name: String, location: Location }, + IllegalState { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to wait for repeated task {} to stop", name))] WaitGcTaskStop { name: String, #[snafu(source)] error: JoinError, + #[snafu(implicit)] location: Location, }, } diff --git a/src/common/substrait/src/error.rs b/src/common/substrait/src/error.rs index 8c235964639e..07cc310d3934 100644 --- a/src/common/substrait/src/error.rs +++ b/src/common/substrait/src/error.rs @@ -27,24 +27,38 @@ use snafu::{Location, Snafu}; #[stack_trace_debug] pub enum Error { #[snafu(display("Unsupported physical plan: {}", name))] - UnsupportedPlan { name: String, location: Location }, + UnsupportedPlan { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unsupported expr: {}", name))] - UnsupportedExpr { name: String, location: Location }, + UnsupportedExpr { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unsupported concrete type: {:?}", ty))] UnsupportedConcreteType { ty: ConcreteDataType, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unsupported substrait type: {}", ty))] - UnsupportedSubstraitType { ty: String, location: Location }, + UnsupportedSubstraitType { + ty: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to decode substrait relation"))] DecodeRel { #[snafu(source)] error: DecodeError, + #[snafu(implicit)] location: Location, }, @@ -52,40 +66,57 @@ pub enum Error { EncodeRel { #[snafu(source)] error: EncodeError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Input plan is empty"))] - EmptyPlan { location: Location }, + EmptyPlan { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Input expression is empty"))] - EmptyExpr { location: Location }, + EmptyExpr { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Missing required field in protobuf, field: {}, plan: {}", field, plan))] MissingField { field: String, plan: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid parameters: {}", reason))] - InvalidParameters { reason: String, location: Location }, + InvalidParameters { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Internal error from DataFusion"))] DFInternal { #[snafu(source)] error: DataFusionError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Internal error"))] Internal { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Cannot convert plan doesn't belong to GreptimeDB"))] - UnknownPlan { location: Location }, + UnknownPlan { + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Schema from Substrait proto doesn't match with the schema in storage. @@ -97,11 +128,13 @@ pub enum Error { SchemaNotMatch { substrait_schema: datafusion::arrow::datatypes::SchemaRef, storage_schema: datafusion::arrow::datatypes::SchemaRef, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to convert DataFusion schema"))] ConvertDfSchema { + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, @@ -109,6 +142,7 @@ pub enum Error { #[snafu(display("Unable to resolve table: {table_name}, error: "))] ResolveTable { table_name: String, + #[snafu(implicit)] location: Location, source: catalog::error::Error, }, @@ -117,6 +151,7 @@ pub enum Error { EncodeDfPlan { #[snafu(source)] error: datafusion::error::DataFusionError, + #[snafu(implicit)] location: Location, }, @@ -124,6 +159,7 @@ pub enum Error { DecodeDfPlan { #[snafu(source)] error: datafusion::error::DataFusionError, + #[snafu(implicit)] location: Location, }, } diff --git a/src/common/time/src/error.rs b/src/common/time/src/error.rs index df4f0883b7a8..bc2d8600e2ef 100644 --- a/src/common/time/src/error.rs +++ b/src/common/time/src/error.rs @@ -33,28 +33,46 @@ pub enum Error { }, #[snafu(display("Invalid date string, raw: {}", raw))] - InvalidDateStr { raw: String, location: Location }, + InvalidDateStr { + raw: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to parse a string into Timestamp, raw string: {}", raw))] - ParseTimestamp { raw: String, location: Location }, + ParseTimestamp { + raw: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to parse a string into Interval, raw string: {}", raw))] - ParseInterval { raw: String, location: Location }, + ParseInterval { + raw: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Current timestamp overflow"))] TimestampOverflow { #[snafu(source)] error: TryFromIntError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Timestamp arithmetic overflow, msg: {}", msg))] - ArithmeticOverflow { msg: String, location: Location }, + ArithmeticOverflow { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid timezone offset: {hours}:{minutes}"))] InvalidTimezoneOffset { hours: i32, minutes: u32, + #[snafu(implicit)] location: Location, }, @@ -63,17 +81,23 @@ pub enum Error { raw: String, #[snafu(source)] error: ParseIntError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid timezone string {raw}"))] - ParseTimezoneName { raw: String, location: Location }, + ParseTimezoneName { + raw: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to format, pattern: {}", pattern))] Format { pattern: String, #[snafu(source)] error: std::fmt::Error, + #[snafu(implicit)] location: Location, }, } diff --git a/src/datanode/src/error.rs b/src/datanode/src/error.rs index 008f7d0ae4d9..17233a41a429 100644 --- a/src/datanode/src/error.rs +++ b/src/datanode/src/error.rs @@ -30,12 +30,14 @@ use table::error::Error as TableError; pub enum Error { #[snafu(display("Failed to execute async task"))] AsyncTaskExecute { + #[snafu(implicit)] location: Location, source: Arc, }, #[snafu(display("Failed to watch change"))] WatchAsyncTaskChange { + #[snafu(implicit)] location: Location, #[snafu(source)] error: tokio::sync::watch::error::RecvError, @@ -43,39 +45,58 @@ pub enum Error { #[snafu(display("Failed to handle heartbeat response"))] HandleHeartbeatResponse { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to get info from meta server"))] GetMetadata { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to execute logical plan"))] ExecuteLogicalPlan { + #[snafu(implicit)] location: Location, source: query::error::Error, }, #[snafu(display("Failed to decode logical plan"))] DecodeLogicalPlan { + #[snafu(implicit)] location: Location, source: substrait::error::Error, }, #[snafu(display("Incorrect internal state: {}", state))] - IncorrectInternalState { state: String, location: Location }, + IncorrectInternalState { + state: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Catalog not found: {}", name))] - CatalogNotFound { name: String, location: Location }, + CatalogNotFound { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Schema not found: {}", name))] - SchemaNotFound { name: String, location: Location }, + SchemaNotFound { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Missing timestamp column in request"))] - MissingTimestampColumn { location: Location }, + MissingTimestampColumn { + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Columns and values number mismatch, columns: {}, values: {}", @@ -87,12 +108,14 @@ pub enum Error { #[snafu(display("Failed to delete value from table: {}", table_name))] Delete { table_name: String, + #[snafu(implicit)] location: Location, source: TableError, }, #[snafu(display("Failed to start server"))] StartServer { + #[snafu(implicit)] location: Location, source: servers::error::Error, }, @@ -120,6 +143,7 @@ pub enum Error { #[snafu(display("Failed to open log store"))] OpenLogStore { + #[snafu(implicit)] location: Location, source: Box, }, @@ -128,17 +152,22 @@ pub enum Error { InitBackend { #[snafu(source)] error: object_store::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Runtime resource error"))] RuntimeResource { + #[snafu(implicit)] location: Location, source: common_runtime::error::Error, }, #[snafu(display("Expect KvBackend but not found"))] - MissingKvBackend { location: Location }, + MissingKvBackend { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid SQL, error: {}", msg))] InvalidSql { msg: String }, @@ -147,22 +176,36 @@ pub enum Error { NotSupportSql { msg: String }, #[snafu(display("Specified timestamp key or primary key column not found: {}", name))] - KeyColumnNotFound { name: String, location: Location }, + KeyColumnNotFound { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Illegal primary keys definition: {}", msg))] - IllegalPrimaryKeysDef { msg: String, location: Location }, + IllegalPrimaryKeysDef { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Schema {} already exists", name))] - SchemaExists { name: String, location: Location }, + SchemaExists { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to access catalog"))] Catalog { + #[snafu(implicit)] location: Location, source: catalog::error::Error, }, #[snafu(display("Failed to initialize meta client"))] MetaClientInit { + #[snafu(implicit)] location: Location, source: meta_client::error::Error, }, @@ -170,13 +213,23 @@ pub enum Error { #[snafu(display( "Table id provider not found, cannot execute SQL directly on datanode in distributed mode" ))] - TableIdProviderNotFound { location: Location }, + TableIdProviderNotFound { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Missing node id in Datanode config"))] - MissingNodeId { location: Location }, + MissingNodeId { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Missing required field: {}", name))] - MissingRequiredField { name: String, location: Location }, + MissingRequiredField { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Cannot find requested database: {}-{}", catalog, schema))] DatabaseNotFound { catalog: String, schema: String }, @@ -185,35 +238,49 @@ pub enum Error { "No valid default value can be built automatically, column: {}", column, ))] - ColumnNoneDefaultValue { column: String, location: Location }, + ColumnNoneDefaultValue { + column: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to shutdown server"))] ShutdownServer { + #[snafu(implicit)] location: Location, source: servers::error::Error, }, #[snafu(display("Failed to shutdown instance"))] ShutdownInstance { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Payload not exist"))] - PayloadNotExist { location: Location }, + PayloadNotExist { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Missing WAL dir config"))] - MissingWalDirConfig { location: Location }, + MissingWalDirConfig { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unexpected, violated: {}", violated))] Unexpected { violated: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to handle request for region {}", region_id))] HandleRegionRequest { region_id: RegionId, + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -221,35 +288,48 @@ pub enum Error { #[snafu(display("RegionId {} not found", region_id))] RegionNotFound { region_id: RegionId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Region {} not ready", region_id))] RegionNotReady { region_id: RegionId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Region {} is busy", region_id))] RegionBusy { region_id: RegionId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Region engine {} is not registered", name))] - RegionEngineNotFound { name: String, location: Location }, + RegionEngineNotFound { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unsupported gRPC request, kind: {}", kind))] - UnsupportedGrpcRequest { kind: String, location: Location }, + UnsupportedGrpcRequest { + kind: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unsupported output type, expected: {}", expected))] UnsupportedOutput { expected: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to build region requests"))] BuildRegionRequests { + #[snafu(implicit)] location: Location, source: store_api::metadata::MetadataError, }, @@ -257,6 +337,7 @@ pub enum Error { #[snafu(display("Failed to stop region engine {}", name))] StopRegionEngine { name: String, + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -268,12 +349,14 @@ pub enum Error { FindLogicalRegions { physical_region_id: RegionId, source: metric_engine::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to build mito engine"))] BuildMitoEngine { source: mito2::error::Error, + #[snafu(implicit)] location: Location, }, } diff --git a/src/datatypes/src/error.rs b/src/datatypes/src/error.rs index df56be87b402..f161d13a9888 100644 --- a/src/datatypes/src/error.rs +++ b/src/datatypes/src/error.rs @@ -27,6 +27,7 @@ pub enum Error { Serialize { #[snafu(source)] error: serde_json::Error, + #[snafu(implicit)] location: Location, }, @@ -34,26 +35,37 @@ pub enum Error { Deserialize { #[snafu(source)] error: serde_json::Error, + #[snafu(implicit)] location: Location, json: String, }, #[snafu(display("Failed to convert datafusion type: {}", from))] - Conversion { from: String, location: Location }, + Conversion { + from: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Bad array access, Index out of bounds: {}, size: {}", index, size))] BadArrayAccess { index: usize, size: usize, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unknown vector, {}", msg))] - UnknownVector { msg: String, location: Location }, + UnknownVector { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unsupported arrow data type, type: {:?}", arrow_type))] UnsupportedArrowType { arrow_type: arrow::datatypes::DataType, + #[snafu(implicit)] location: Location, }, @@ -61,6 +73,7 @@ pub enum Error { UnsupportedOperation { op: String, vector_type: String, + #[snafu(implicit)] location: Location, }, @@ -69,19 +82,29 @@ pub enum Error { value: String, #[snafu(source)] error: std::num::ParseIntError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid timestamp index: {}", index))] - InvalidTimestampIndex { index: usize, location: Location }, + InvalidTimestampIndex { + index: usize, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("{}", msg))] - CastType { msg: String, location: Location }, + CastType { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to cast arrow time i32 type into i64"))] CastTimeType { #[snafu(source)] error: std::num::TryFromIntError, + #[snafu(implicit)] location: Location, }, @@ -89,6 +112,7 @@ pub enum Error { ArrowCompute { #[snafu(source)] error: arrow::error::ArrowError, + #[snafu(implicit)] location: Location, }, @@ -96,32 +120,64 @@ pub enum Error { ProjectArrowSchema { #[snafu(source)] error: arrow::error::ArrowError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unsupported column default constraint expression: {}", expr))] - UnsupportedDefaultExpr { expr: String, location: Location }, + UnsupportedDefaultExpr { + expr: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Default value should not be null for non null column"))] - NullDefault { location: Location }, + NullDefault { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Incompatible default value type, reason: {}", reason))] - DefaultValueType { reason: String, location: Location }, + DefaultValueType { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Duplicated metadata for {}", key))] - DuplicateMeta { key: String, location: Location }, + DuplicateMeta { + key: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to convert value into scalar value, reason: {}", reason))] - ToScalarValue { reason: String, location: Location }, + ToScalarValue { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid timestamp precision: {}", precision))] - InvalidTimestampPrecision { precision: u64, location: Location }, + InvalidTimestampPrecision { + precision: u64, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Column {} already exists", column))] - DuplicateColumn { column: String, location: Location }, + DuplicateColumn { + column: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to unpack value to given type: {}", reason))] - TryFromValue { reason: String, location: Location }, + TryFromValue { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to specify the precision {} and scale {}", precision, scale))] InvalidPrecisionOrScale { @@ -129,6 +185,7 @@ pub enum Error { scale: i8, #[snafu(source)] error: arrow::error::ArrowError, + #[snafu(implicit)] location: Location, }, @@ -137,6 +194,7 @@ pub enum Error { precision: u8, #[snafu(source)] error: arrow::error::ArrowError, + #[snafu(implicit)] location: Location, }, @@ -144,6 +202,7 @@ pub enum Error { ConvertArrowArrayToScalars { #[snafu(source)] error: datafusion_common::DataFusionError, + #[snafu(implicit)] location: Location, }, } diff --git a/src/file-engine/src/error.rs b/src/file-engine/src/error.rs index 5a23354fc3ef..b5ddbe842d39 100644 --- a/src/file-engine/src/error.rs +++ b/src/file-engine/src/error.rs @@ -30,27 +30,35 @@ pub enum Error { #[snafu(display("Unsupported operation: {}", operation))] Unsupported { operation: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unexpected engine: {}", engine))] - UnexpectedEngine { engine: String, location: Location }, + UnexpectedEngine { + engine: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid region metadata"))] InvalidMetadata { source: store_api::metadata::MetadataError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Region not found, region_id: {}", region_id))] RegionNotFound { region_id: RegionId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to check object from path: {}", path))] CheckObject { path: String, + #[snafu(implicit)] location: Location, #[snafu(source)] error: object_store::Error, @@ -58,6 +66,7 @@ pub enum Error { #[snafu(display("Fail to encode object into json"))] EncodeJson { + #[snafu(implicit)] location: Location, #[snafu(source)] error: JsonError, @@ -65,6 +74,7 @@ pub enum Error { #[snafu(display("Fail to decode object from json"))] DecodeJson { + #[snafu(implicit)] location: Location, #[snafu(source)] error: JsonError, @@ -75,6 +85,7 @@ pub enum Error { #[snafu(source)] error: object_store::Error, region_id: RegionId, + #[snafu(implicit)] location: Location, }, @@ -83,6 +94,7 @@ pub enum Error { #[snafu(source)] error: object_store::Error, region_id: RegionId, + #[snafu(implicit)] location: Location, }, @@ -91,17 +103,27 @@ pub enum Error { #[snafu(source)] error: object_store::Error, region_id: RegionId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Manifest already exists: {}", path))] - ManifestExists { path: String, location: Location }, + ManifestExists { + path: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Missing required field: {}", name))] - MissingRequiredField { name: String, location: Location }, + MissingRequiredField { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to build backend"))] BuildBackend { + #[snafu(implicit)] location: Location, source: common_datasource::error::Error, }, @@ -110,6 +132,7 @@ pub enum Error { BuildCsvConfig { #[snafu(source)] error: common_datasource::file_format::csv::CsvConfigBuilderError, + #[snafu(implicit)] location: Location, }, @@ -117,6 +140,7 @@ pub enum Error { BuildStream { #[snafu(source)] error: DataFusionError, + #[snafu(implicit)] location: Location, }, @@ -124,23 +148,27 @@ pub enum Error { ProjectArrowSchema { #[snafu(source)] error: ArrowError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to project schema"))] ProjectSchema { source: datatypes::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to build stream adapter"))] BuildStreamAdapter { + #[snafu(implicit)] location: Location, source: common_recordbatch::error::Error, }, #[snafu(display("Failed to parse file format"))] ParseFileFormat { + #[snafu(implicit)] location: Location, source: common_datasource::error::Error, }, @@ -149,6 +177,7 @@ pub enum Error { ParquetScanPlan { #[snafu(source)] error: DataFusionError, + #[snafu(implicit)] location: Location, }, @@ -160,6 +189,7 @@ pub enum Error { ProjectionOutOfBounds { column_index: usize, bounds: usize, + #[snafu(implicit)] location: Location, }, @@ -167,6 +197,7 @@ pub enum Error { ExtractColumnFromFilter { #[snafu(source)] error: DataFusionError, + #[snafu(implicit)] location: Location, }, @@ -174,11 +205,16 @@ pub enum Error { CreateDefault { column: String, source: datatypes::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Missing default value for column: {}", column))] - MissingColumnNoDefault { column: String, location: Location }, + MissingColumnNoDefault { + column: String, + #[snafu(implicit)] + location: Location, + }, } pub type Result = std::result::Result; diff --git a/src/flow/src/adapter/error.rs b/src/flow/src/adapter/error.rs index dc384fe6c9ff..03e244666d71 100644 --- a/src/flow/src/adapter/error.rs +++ b/src/flow/src/adapter/error.rs @@ -36,41 +36,72 @@ pub enum Error { #[snafu(display("Failed to eval stream"))] Eval { source: EvalError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Table not found: {name}"))] - TableNotFound { name: String, location: Location }, + TableNotFound { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Table already exist: {name}"))] - TableAlreadyExist { name: String, location: Location }, + TableAlreadyExist { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to join task"))] JoinTask { #[snafu(source)] error: tokio::task::JoinError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid query: {reason}"))] - InvalidQuery { reason: String, location: Location }, + InvalidQuery { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("No protobuf type for value: {value}"))] - NoProtoType { value: Value, location: Location }, + NoProtoType { + value: Value, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Not implement in flow: {reason}"))] - NotImplemented { reason: String, location: Location }, + NotImplemented { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Flow plan error: {reason}"))] - Plan { reason: String, location: Location }, + Plan { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unsupported temporal filter: {reason}"))] - UnsupportedTemporalFilter { reason: String, location: Location }, + UnsupportedTemporalFilter { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Datatypes error: {source} with extra message: {extra}"))] Datatypes { source: datatypes::Error, extra: String, + #[snafu(implicit)] location: Location, }, @@ -78,6 +109,7 @@ pub enum Error { Datafusion { raw: datafusion_common::DataFusionError, context: String, + #[snafu(implicit)] location: Location, }, } diff --git a/src/flow/src/expr/error.rs b/src/flow/src/expr/error.rs index bcdcfe36be40..20a6a2449023 100644 --- a/src/flow/src/expr/error.rs +++ b/src/flow/src/expr/error.rs @@ -31,24 +31,33 @@ use snafu::{Location, Snafu}; #[stack_trace_debug] pub enum EvalError { #[snafu(display("Division by zero"))] - DivisionByZero { location: Location }, + DivisionByZero { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Type mismatch: expected {expected}, actual {actual}"))] TypeMismatch { expected: ConcreteDataType, actual: ConcreteDataType, + #[snafu(implicit)] location: Location, }, /// can't nest datatypes error because EvalError need to be store in map and serialization #[snafu(display("Fail to unpack from value to given type: {msg}"))] - TryFromValue { msg: String, location: Location }, + TryFromValue { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Fail to cast value of type {from} to given type {to}"))] CastValue { from: ConcreteDataType, to: ConcreteDataType, source: datatypes::Error, + #[snafu(implicit)] location: Location, }, @@ -56,18 +65,34 @@ pub enum EvalError { DataType { msg: String, source: datatypes::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid argument: {reason}"))] - InvalidArgument { reason: String, location: Location }, + InvalidArgument { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Internal error: {reason}"))] - Internal { reason: String, location: Location }, + Internal { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Optimize error: {reason}"))] - Optimize { reason: String, location: Location }, + Optimize { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Overflowed during evaluation"))] - Overflow { location: Location }, + Overflow { + #[snafu(implicit)] + location: Location, + }, } diff --git a/src/frontend/src/error.rs b/src/frontend/src/error.rs index 7c4d35c674fc..4cceb710de3c 100644 --- a/src/frontend/src/error.rs +++ b/src/frontend/src/error.rs @@ -28,48 +28,56 @@ use store_api::storage::RegionNumber; pub enum Error { #[snafu(display("Failed to invalidate table cache"))] InvalidateTableCache { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to open raft engine backend"))] OpenRaftEngineBackend { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Failed to handle heartbeat response"))] HandleHeartbeatResponse { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("External error"))] External { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Failed to query"))] RequestQuery { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Runtime resource error"))] RuntimeResource { + #[snafu(implicit)] location: Location, source: common_runtime::error::Error, }, #[snafu(display("Failed to start server"))] StartServer { + #[snafu(implicit)] location: Location, source: servers::error::Error, }, #[snafu(display("Failed to shutdown server"))] ShutdownServer { + #[snafu(implicit)] location: Location, source: servers::error::Error, }, @@ -83,42 +91,66 @@ pub enum Error { #[snafu(display("Failed to parse SQL"))] ParseSql { + #[snafu(implicit)] location: Location, source: sql::error::Error, }, #[snafu(display("Failed to convert vector to GRPC column, reason: {}", reason))] - VectorToGrpcColumn { reason: String, location: Location }, + VectorToGrpcColumn { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid SQL, error: {}", err_msg))] - InvalidSql { err_msg: String, location: Location }, + InvalidSql { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Incomplete GRPC request: {}", err_msg))] - IncompleteGrpcRequest { err_msg: String, location: Location }, + IncompleteGrpcRequest { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to find Datanode by region: {:?}", region))] FindDatanode { region: RegionNumber, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid InsertRequest, reason: {}", reason))] - InvalidInsertRequest { reason: String, location: Location }, + InvalidInsertRequest { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid DeleteRequest, reason: {}", reason))] - InvalidDeleteRequest { reason: String, location: Location }, + InvalidDeleteRequest { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Table not found: {}", table_name))] TableNotFound { table_name: String }, #[snafu(display("General catalog error"))] Catalog { + #[snafu(implicit)] location: Location, source: catalog::error::Error, }, #[snafu(display("Failed to start Meta client"))] StartMetaClient { + #[snafu(implicit)] location: Location, source: meta_client::error::Error, }, @@ -126,30 +158,42 @@ pub enum Error { #[snafu(display("Failed to create heartbeat stream to Metasrv"))] CreateMetaHeartbeatStream { source: meta_client::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to find table route for table id {}", table_id))] FindTableRoute { table_id: u32, + #[snafu(implicit)] location: Location, source: partition::error::Error, }, #[snafu(display("Schema {} already exists", name))] - SchemaExists { name: String, location: Location }, + SchemaExists { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Table occurs error"))] Table { + #[snafu(implicit)] location: Location, source: table::error::Error, }, #[snafu(display("Cannot find column by name: {}", msg))] - ColumnNotFound { msg: String, location: Location }, + ColumnNotFound { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to plan statement"))] PlanStatement { + #[snafu(implicit)] location: Location, source: query::error::Error, }, @@ -157,33 +201,45 @@ pub enum Error { #[snafu(display("Failed to read table: {table_name}"))] ReadTable { table_name: String, + #[snafu(implicit)] location: Location, source: query::error::Error, }, #[snafu(display("Failed to execute logical plan"))] ExecLogicalPlan { + #[snafu(implicit)] location: Location, source: query::error::Error, }, #[snafu(display("Operation to region server failed"))] InvokeRegionServer { + #[snafu(implicit)] location: Location, source: servers::error::Error, }, #[snafu(display("Failed to find leaders when altering table, table: {}", table))] - LeaderNotFound { table: String, location: Location }, + LeaderNotFound { + table: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to found context value: {}", key))] - ContextValueNotFound { key: String, location: Location }, + ContextValueNotFound { + key: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Not supported: {}", feat))] NotSupported { feat: String }, #[snafu(display("SQL execution intercepted"))] SqlExecIntercepted { + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -192,27 +248,35 @@ pub enum Error { #[snafu(display("Failed to execute PromQL query {}", query))] ExecutePromql { query: String, + #[snafu(implicit)] location: Location, source: servers::error::Error, }, #[snafu(display("Failed to create logical plan for prometheus query"))] PromStoreRemoteQueryPlan { + #[snafu(implicit)] location: Location, source: servers::error::Error, }, #[snafu(display("Failed to describe schema for given statement"))] DescribeStatement { + #[snafu(implicit)] location: Location, source: query::error::Error, }, #[snafu(display("Illegal primary keys definition: {}", msg))] - IllegalPrimaryKeysDef { msg: String, location: Location }, + IllegalPrimaryKeysDef { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to start script manager"))] StartScriptManager { + #[snafu(implicit)] location: Location, source: script::error::Error, }, @@ -220,6 +284,7 @@ pub enum Error { #[snafu(display("Failed to copy table: {}", table_name))] CopyTable { table_name: String, + #[snafu(implicit)] location: Location, source: table::error::Error, }, @@ -227,27 +292,41 @@ pub enum Error { #[snafu(display("Failed to insert value into table: {}", table_name))] Insert { table_name: String, + #[snafu(implicit)] location: Location, source: table::error::Error, }, #[snafu(display("Unsupported format: {:?}", format))] - UnsupportedFormat { location: Location, format: Format }, + UnsupportedFormat { + #[snafu(implicit)] + location: Location, + format: Format, + }, #[snafu(display("Failed to pass permission check"))] Permission { source: auth::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Empty data: {}", msg))] - EmptyData { msg: String, location: Location }, + EmptyData { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "No valid default value can be built automatically, column: {}", column, ))] - ColumnNoneDefaultValue { column: String, location: Location }, + ColumnNoneDefaultValue { + column: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid region request, reason: {}", reason))] InvalidRegionRequest { reason: String }, @@ -255,6 +334,7 @@ pub enum Error { #[snafu(display("Table operation error"))] TableOperation { source: operator::error::Error, + #[snafu(implicit)] location: Location, }, diff --git a/src/index/src/inverted_index/error.rs b/src/index/src/inverted_index/error.rs index d831eaa1b12c..0e151db71893 100644 --- a/src/index/src/inverted_index/error.rs +++ b/src/index/src/inverted_index/error.rs @@ -30,6 +30,7 @@ pub enum Error { Seek { #[snafu(source)] error: IoError, + #[snafu(implicit)] location: Location, }, @@ -37,6 +38,7 @@ pub enum Error { Read { #[snafu(source)] error: IoError, + #[snafu(implicit)] location: Location, }, @@ -44,6 +46,7 @@ pub enum Error { Write { #[snafu(source)] error: IoError, + #[snafu(implicit)] location: Location, }, @@ -51,6 +54,7 @@ pub enum Error { Flush { #[snafu(source)] error: IoError, + #[snafu(implicit)] location: Location, }, @@ -58,6 +62,7 @@ pub enum Error { Close { #[snafu(source)] error: IoError, + #[snafu(implicit)] location: Location, }, @@ -67,6 +72,7 @@ pub enum Error { UnexpectedBlobSize { min_blob_size: u64, actual_blob_size: u64, + #[snafu(implicit)] location: Location, }, @@ -74,6 +80,7 @@ pub enum Error { UnexpectedFooterPayloadSize { max_payload_size: u64, actual_payload_size: u64, + #[snafu(implicit)] location: Location, }, @@ -86,12 +93,16 @@ pub enum Error { }, #[snafu(display("Unexpected zero segment row count"))] - UnexpectedZeroSegmentRowCount { location: Location }, + UnexpectedZeroSegmentRowCount { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to decode fst"))] DecodeFst { #[snafu(source)] error: fst::Error, + #[snafu(implicit)] location: Location, }, @@ -99,6 +110,7 @@ pub enum Error { DecodeProto { #[snafu(source)] error: prost::DecodeError, + #[snafu(implicit)] location: Location, }, @@ -107,6 +119,7 @@ pub enum Error { #[snafu(source)] error: regex::Error, pattern: String, + #[snafu(implicit)] location: Location, }, @@ -114,33 +127,49 @@ pub enum Error { ParseDFA { #[snafu(source)] error: Box, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unexpected empty predicates to construct fst applier"))] - EmptyPredicates { location: Location }, + EmptyPredicates { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to construct intersection fst applier with InList predicate"))] - IntersectionApplierWithInList { location: Location }, + IntersectionApplierWithInList { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to construct keys fst applier without InList predicate"))] - KeysApplierWithoutInList { location: Location }, + KeysApplierWithoutInList { + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Failed to construct keys fst applier with unexpected predicates: {predicates:?}" ))] KeysApplierUnexpectedPredicates { + #[snafu(implicit)] location: Location, predicates: Vec, }, #[snafu(display("index not found, name: {name}"))] - IndexNotFound { name: String, location: Location }, + IndexNotFound { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to insert value to FST"))] FstInsert { #[snafu(source)] error: fst::Error, + #[snafu(implicit)] location: Location, }, @@ -148,6 +177,7 @@ pub enum Error { FstCompile { #[snafu(source)] error: fst::Error, + #[snafu(implicit)] location: Location, }, @@ -155,11 +185,16 @@ pub enum Error { CommonIoError { #[snafu(source)] error: IoError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unknown intermediate codec magic: {magic:?}"))] - UnknownIntermediateCodecMagic { magic: [u8; 4], location: Location }, + UnknownIntermediateCodecMagic { + magic: [u8; 4], + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Inconsistent row count, index_name: {index_name}, total_row_count: {total_row_count}, expected: {expected_row_count}"))] InconsistentRowCount { @@ -171,6 +206,7 @@ pub enum Error { #[snafu(display("External error"))] External { source: BoxedError, + #[snafu(implicit)] location: Location, }, } diff --git a/src/log-store/src/error.rs b/src/log-store/src/error.rs index edb06b42ca7f..45449c9d65e8 100644 --- a/src/log-store/src/error.rs +++ b/src/log-store/src/error.rs @@ -29,12 +29,14 @@ use crate::kafka::NamespaceImpl as KafkaNamespace; pub enum Error { #[snafu(display("Failed to start log store gc task"))] StartGcTask { + #[snafu(implicit)] location: Location, source: RuntimeError, }, #[snafu(display("Failed to stop log store gc task"))] StopGcTask { + #[snafu(implicit)] location: Location, source: RuntimeError, }, @@ -43,6 +45,7 @@ pub enum Error { AddEntryLogBatch { #[snafu(source)] error: raft_engine::Error, + #[snafu(implicit)] location: Location, }, @@ -50,6 +53,7 @@ pub enum Error { RaftEngine { #[snafu(source)] error: raft_engine::Error, + #[snafu(implicit)] location: Location, }, @@ -58,14 +62,22 @@ pub enum Error { path: String, #[snafu(source)] error: std::io::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Log store not started yet"))] - IllegalState { location: Location }, + IllegalState { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Namespace is illegal: {}", ns))] - IllegalNamespace { ns: u64, location: Location }, + IllegalNamespace { + ns: u64, + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Failed to fetch entries from namespace: {}, start: {}, end: {}, max size: {}", @@ -81,6 +93,7 @@ pub enum Error { max_size: usize, #[snafu(source)] error: raft_engine::Error, + #[snafu(implicit)] location: Location, }, @@ -94,6 +107,7 @@ pub enum Error { namespace: u64, first_index: u64, attempt_index: u64, + #[snafu(implicit)] location: Location, }, @@ -103,6 +117,7 @@ pub enum Error { ))] BuildClient { broker_endpoints: Vec, + #[snafu(implicit)] location: Location, #[snafu(source)] error: rskafka::client::error::Error, @@ -119,6 +134,7 @@ pub enum Error { BuildPartitionClient { topic: String, partition: i32, + #[snafu(implicit)] location: Location, #[snafu(source)] error: rskafka::client::error::Error, @@ -131,18 +147,28 @@ pub enum Error { ))] GetClient { topic: String, + #[snafu(implicit)] location: Location, error: String, }, #[snafu(display("Missing required key in a record"))] - MissingKey { location: Location }, + MissingKey { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Missing required value in a record"))] - MissingValue { location: Location }, + MissingValue { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Cannot build a record from empty entries"))] - EmptyEntries { location: Location }, + EmptyEntries { + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Failed to produce records to Kafka, topic: {}, size: {}, limit: {}", @@ -154,6 +180,7 @@ pub enum Error { topic: String, size: usize, limit: usize, + #[snafu(implicit)] location: Location, #[snafu(source)] error: rskafka::client::producer::Error, @@ -162,6 +189,7 @@ pub enum Error { #[snafu(display("Failed to read a record from Kafka, ns: {}", ns))] ConsumeRecord { ns: KafkaNamespace, + #[snafu(implicit)] location: Location, #[snafu(source)] error: rskafka::client::error::Error, @@ -170,16 +198,21 @@ pub enum Error { #[snafu(display("Failed to get the latest offset, ns: {}", ns))] GetOffset { ns: KafkaNamespace, + #[snafu(implicit)] location: Location, #[snafu(source)] error: rskafka::client::error::Error, }, #[snafu(display("Failed to do a cast"))] - Cast { location: Location }, + Cast { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to encode object into json"))] EncodeJson { + #[snafu(implicit)] location: Location, #[snafu(source)] error: JsonError, @@ -187,13 +220,18 @@ pub enum Error { #[snafu(display("Failed to decode object from json"))] DecodeJson { + #[snafu(implicit)] location: Location, #[snafu(source)] error: JsonError, }, #[snafu(display("The record sequence is not legal, error: {}", error))] - IllegalSequence { location: Location, error: String }, + IllegalSequence { + #[snafu(implicit)] + location: Location, + error: String, + }, #[snafu(display( "Attempt to append discontinuous log entry, region: {}, last index: {}, attempt index: {}", diff --git a/src/meta-client/src/error.rs b/src/meta-client/src/error.rs index fcb6e82ccf73..9116598590dc 100644 --- a/src/meta-client/src/error.rs +++ b/src/meta-client/src/error.rs @@ -24,19 +24,30 @@ use tonic::Status; #[stack_trace_debug] pub enum Error { #[snafu(display("Illegal GRPC client state: {}", err_msg))] - IllegalGrpcClientState { err_msg: String, location: Location }, + IllegalGrpcClientState { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("{}", msg))] MetaServer { code: StatusCode, msg: String }, #[snafu(display("Failed to ask leader from all endpoints"))] - AskLeader { location: Location }, + AskLeader { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("No leader, should ask leader first"))] - NoLeader { location: Location }, + NoLeader { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Ask leader timeout"))] AskLeaderTimeout { + #[snafu(implicit)] location: Location, #[snafu(source)] error: tokio::time::error::Elapsed, @@ -44,33 +55,48 @@ pub enum Error { #[snafu(display("Failed to create gRPC channel"))] CreateChannel { + #[snafu(implicit)] location: Location, source: common_grpc::error::Error, }, #[snafu(display("{} not started", name))] - NotStarted { name: String, location: Location }, + NotStarted { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to send heartbeat: {}", err_msg))] - SendHeartbeat { err_msg: String, location: Location }, + SendHeartbeat { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed create heartbeat stream to server"))] - CreateHeartbeatStream { location: Location }, + CreateHeartbeatStream { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid response header"))] InvalidResponseHeader { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to convert Metasrv request"))] ConvertMetaRequest { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to convert Metasrv response"))] ConvertMetaResponse { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, diff --git a/src/meta-srv/src/error.rs b/src/meta-srv/src/error.rs index c643528dddad..0a53f0a6678a 100644 --- a/src/meta-srv/src/error.rs +++ b/src/meta-srv/src/error.rs @@ -33,16 +33,25 @@ use crate::pubsub::Message; #[stack_trace_debug] pub enum Error { #[snafu(display("The target peer is unavailable temporally: {}", peer_id))] - PeerUnavailable { location: Location, peer_id: u64 }, + PeerUnavailable { + #[snafu(implicit)] + location: Location, + peer_id: u64, + }, #[snafu(display("Another migration procedure is running for region: {}", region_id))] MigrationRunning { + #[snafu(implicit)] location: Location, region_id: RegionId, }, #[snafu(display("The region migration procedure aborted, reason: {}", reason))] - MigrationAbort { location: Location, reason: String }, + MigrationAbort { + #[snafu(implicit)] + location: Location, + reason: String, + }, #[snafu(display( "Another procedure is opening the region: {} on peer: {}", @@ -50,6 +59,7 @@ pub enum Error { peer_id ))] RegionOpeningRace { + #[snafu(implicit)] location: Location, peer_id: DatanodeId, region_id: RegionId, @@ -57,42 +67,49 @@ pub enum Error { #[snafu(display("Failed to init ddl manager"))] InitDdlManager { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to create default catalog and schema"))] InitMetadata { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to allocate next sequence number"))] NextSequence { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to start telemetry task"))] StartTelemetryTask { + #[snafu(implicit)] location: Location, source: common_runtime::error::Error, }, #[snafu(display("Failed to submit ddl task"))] SubmitDdlTask { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to invalidate table cache"))] InvalidateTableCache { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to operate region on peer:{}", peer))] OperateRegion { + #[snafu(implicit)] location: Location, peer: Peer, source: BoxedError, @@ -100,12 +117,14 @@ pub enum Error { #[snafu(display("Failed to list catalogs"))] ListCatalogs { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Failed to list {}'s schemas", catalog))] ListSchemas { + #[snafu(implicit)] location: Location, catalog: String, source: BoxedError, @@ -113,6 +132,7 @@ pub enum Error { #[snafu(display("Failed to list {}.{}'s tables", catalog, schema))] ListTables { + #[snafu(implicit)] location: Location, catalog: String, schema: String, @@ -121,13 +141,18 @@ pub enum Error { #[snafu(display("Failed to join a future"))] Join { + #[snafu(implicit)] location: Location, #[snafu(source)] error: JoinError, }, #[snafu(display("Failed to execute transaction: {}", msg))] - Txn { location: Location, msg: String }, + Txn { + #[snafu(implicit)] + location: Location, + msg: String, + }, #[snafu(display( "Unexpected table_id changed, expected: {}, found: {}", @@ -135,6 +160,7 @@ pub enum Error { found, ))] TableIdChanged { + #[snafu(implicit)] location: Location, expected: u64, found: u64, @@ -146,6 +172,7 @@ pub enum Error { available ))] NoEnoughAvailableDatanode { + #[snafu(implicit)] location: Location, required: usize, available: usize, @@ -153,6 +180,7 @@ pub enum Error { #[snafu(display("Failed to request Datanode {}", peer))] RequestDatanode { + #[snafu(implicit)] location: Location, peer: Peer, source: client::Error, @@ -166,18 +194,23 @@ pub enum Error { #[snafu(display("Failed to shutdown {} server", server))] ShutdownServer { + #[snafu(implicit)] location: Location, source: servers::error::Error, server: String, }, #[snafu(display("Empty key is not allowed"))] - EmptyKey { location: Location }, + EmptyKey { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to execute via Etcd"))] EtcdFailed { #[snafu(source)] error: etcd_client::Error, + #[snafu(implicit)] location: Location, }, @@ -185,6 +218,7 @@ pub enum Error { ConnectEtcd { #[snafu(source)] error: etcd_client::Error, + #[snafu(implicit)] location: Location, }, @@ -193,6 +227,7 @@ pub enum Error { addr: String, #[snafu(source)] error: std::io::Error, + #[snafu(implicit)] location: Location, }, @@ -206,15 +241,18 @@ pub enum Error { StartGrpc { #[snafu(source)] error: tonic::transport::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to start http server"))] StartHttp { + #[snafu(implicit)] location: Location, source: servers::error::Error, }, #[snafu(display("Failed to init export metrics task"))] InitExportMetricsTask { + #[snafu(implicit)] location: Location, source: servers::error::Error, }, @@ -231,21 +269,37 @@ pub enum Error { error: std::net::AddrParseError, }, #[snafu(display("Empty table name"))] - EmptyTableName { location: Location }, + EmptyTableName { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid datanode lease key: {}", key))] - InvalidLeaseKey { key: String, location: Location }, + InvalidLeaseKey { + key: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid datanode stat key: {}", key))] - InvalidStatKey { key: String, location: Location }, + InvalidStatKey { + key: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid inactive region key: {}", key))] - InvalidInactiveRegionKey { key: String, location: Location }, + InvalidInactiveRegionKey { + key: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to parse datanode lease key from utf8"))] LeaseKeyFromUtf8 { #[snafu(source)] error: std::string::FromUtf8Error, + #[snafu(implicit)] location: Location, }, @@ -253,6 +307,7 @@ pub enum Error { LeaseValueFromUtf8 { #[snafu(source)] error: std::string::FromUtf8Error, + #[snafu(implicit)] location: Location, }, @@ -260,6 +315,7 @@ pub enum Error { StatKeyFromUtf8 { #[snafu(source)] error: std::string::FromUtf8Error, + #[snafu(implicit)] location: Location, }, @@ -267,6 +323,7 @@ pub enum Error { StatValueFromUtf8 { #[snafu(source)] error: std::string::FromUtf8Error, + #[snafu(implicit)] location: Location, }, @@ -274,6 +331,7 @@ pub enum Error { InvalidRegionKeyFromUtf8 { #[snafu(source)] error: std::string::FromUtf8Error, + #[snafu(implicit)] location: Location, }, @@ -282,6 +340,7 @@ pub enum Error { input: String, #[snafu(source)] error: serde_json::error::Error, + #[snafu(implicit)] location: Location, }, @@ -290,6 +349,7 @@ pub enum Error { input: String, #[snafu(source)] error: serde_json::error::Error, + #[snafu(implicit)] location: Location, }, @@ -298,6 +358,7 @@ pub enum Error { err_msg: String, #[snafu(source)] error: std::num::ParseIntError, + #[snafu(implicit)] location: Location, }, @@ -306,20 +367,27 @@ pub enum Error { err_msg: String, #[snafu(source)] error: std::str::ParseBoolError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid arguments: {}", err_msg))] - InvalidArguments { err_msg: String, location: Location }, + InvalidArguments { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Cannot parse catalog value"))] InvalidCatalogValue { + #[snafu(implicit)] location: Location, source: common_catalog::error::Error, }, #[snafu(display("Cannot parse full table name"))] InvalidFullTableName { + #[snafu(implicit)] location: Location, source: common_catalog::error::Error, }, @@ -328,24 +396,28 @@ pub enum Error { DecodeTableRoute { #[snafu(source)] error: prost::DecodeError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to find table route for {table_id}"))] TableRouteNotFound { table_id: TableId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to find table route for {region_id}"))] RegionRouteNotFound { region_id: RegionId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Table info not found: {}", table_id))] TableInfoNotFound { table_id: TableId, + #[snafu(implicit)] location: Location, }, @@ -353,6 +425,7 @@ pub enum Error { DatanodeTableNotFound { table_id: TableId, datanode_id: DatanodeId, + #[snafu(implicit)] location: Location, }, @@ -360,35 +433,50 @@ pub enum Error { CorruptedTableRoute { key: String, reason: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Metasrv has no leader at this moment"))] - NoLeader { location: Location }, + NoLeader { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Table {} not found", name))] - TableNotFound { name: String, location: Location }, + TableNotFound { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Failed to move the value of {} because other clients caused a race condition", key ))] - MoveValue { key: String, location: Location }, + MoveValue { + key: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unsupported selector type, {}", selector_type))] UnsupportedSelectorType { selector_type: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unexpected, violated: {violated}"))] Unexpected { violated: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to create gRPC channel"))] CreateChannel { + #[snafu(implicit)] location: Location, source: common_grpc::error::Error, }, @@ -397,6 +485,7 @@ pub enum Error { BatchGet { #[snafu(source)] error: tonic::Status, + #[snafu(implicit)] location: Location, }, @@ -404,15 +493,20 @@ pub enum Error { Range { #[snafu(source)] error: tonic::Status, + #[snafu(implicit)] location: Location, }, #[snafu(display("Response header not found"))] - ResponseHeaderNotFound { location: Location }, + ResponseHeaderNotFound { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("The requested meta node is not leader, node addr: {}", node_addr))] IsNotLeader { node_addr: String, + #[snafu(implicit)] location: Location, }, @@ -420,6 +514,7 @@ pub enum Error { InvalidHttpBody { #[snafu(source)] error: http::Error, + #[snafu(implicit)] location: Location, }, @@ -431,6 +526,7 @@ pub enum Error { ExceededRetryLimit { func_name: String, retry_num: usize, + #[snafu(implicit)] location: Location, }, @@ -438,6 +534,7 @@ pub enum Error { Lock { #[snafu(source)] error: etcd_client::Error, + #[snafu(implicit)] location: Location, }, @@ -445,6 +542,7 @@ pub enum Error { Unlock { #[snafu(source)] error: etcd_client::Error, + #[snafu(implicit)] location: Location, }, @@ -452,16 +550,21 @@ pub enum Error { LeaseGrant { #[snafu(source)] error: etcd_client::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Distributed lock is not configured"))] - LockNotConfig { location: Location }, + LockNotConfig { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid utf-8 value"))] InvalidUtf8Value { #[snafu(source)] error: std::string::FromUtf8Error, + #[snafu(implicit)] location: Location, }, @@ -470,33 +573,42 @@ pub enum Error { #[snafu(display("Failed to start procedure manager"))] StartProcedureManager { + #[snafu(implicit)] location: Location, source: common_procedure::Error, }, #[snafu(display("Failed to stop procedure manager"))] StopProcedureManager { + #[snafu(implicit)] location: Location, source: common_procedure::Error, }, #[snafu(display("Failed to wait procedure done"))] WaitProcedure { + #[snafu(implicit)] location: Location, source: common_procedure::Error, }, #[snafu(display("Failed to query procedure state"))] QueryProcedure { + #[snafu(implicit)] location: Location, source: common_procedure::Error, }, #[snafu(display("Procedure not found: {pid}"))] - ProcedureNotFound { location: Location, pid: String }, + ProcedureNotFound { + #[snafu(implicit)] + location: Location, + pid: String, + }, #[snafu(display("Failed to submit procedure"))] SubmitProcedure { + #[snafu(implicit)] location: Location, source: common_procedure::Error, }, @@ -504,43 +616,63 @@ pub enum Error { #[snafu(display("Schema already exists, name: {schema_name}"))] SchemaAlreadyExists { schema_name: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Table already exists: {table_name}"))] TableAlreadyExists { table_name: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Pusher not found: {pusher_id}"))] PusherNotFound { pusher_id: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to push message: {err_msg}"))] - PushMessage { err_msg: String, location: Location }, + PushMessage { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Mailbox already closed: {id}"))] - MailboxClosed { id: u64, location: Location }, + MailboxClosed { + id: u64, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Mailbox timeout: {id}"))] - MailboxTimeout { id: u64, location: Location }, + MailboxTimeout { + id: u64, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Mailbox receiver got an error: {id}, {err_msg}"))] MailboxReceiver { id: u64, err_msg: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Missing request header"))] - MissingRequestHeader { location: Location }, + MissingRequestHeader { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to register procedure loader, type name: {}", type_name))] RegisterProcedureLoader { type_name: String, + #[snafu(implicit)] location: Location, source: common_procedure::error::Error, }, @@ -548,6 +680,7 @@ pub enum Error { #[snafu(display("Failed to find failover candidates for region: {}", failed_region))] RegionFailoverCandidatesNotFound { failed_region: String, + #[snafu(implicit)] location: Location, }, @@ -559,30 +692,42 @@ pub enum Error { UnexpectedInstructionReply { mailbox_message: String, reason: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Expected to retry later, reason: {}", reason))] - RetryLater { reason: String, location: Location }, + RetryLater { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Expected to retry later, reason: {}", reason))] RetryLaterWithSource { reason: String, + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Failed to update table metadata, err_msg: {}", err_msg))] - UpdateTableMetadata { err_msg: String, location: Location }, + UpdateTableMetadata { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to convert table route"))] TableRouteConversion { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to convert proto data"))] ConvertProtoData { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, @@ -592,49 +737,63 @@ pub enum Error { #[snafu(display("Other error"))] Other { source: BoxedError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Table metadata manager error"))] TableMetadataManager { source: common_meta::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Keyvalue backend error"))] KvBackend { source: common_meta::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to update table route"))] UpdateTableRoute { source: common_meta::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to get table info error"))] GetFullTableInfo { source: common_meta::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid heartbeat request: {}", err_msg))] - InvalidHeartbeatRequest { err_msg: String, location: Location }, + InvalidHeartbeatRequest { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to publish message"))] PublishMessage { #[snafu(source)] error: SendError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Too many partitions"))] - TooManyPartitions { location: Location }, + TooManyPartitions { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unsupported operation {}", operation))] Unsupported { operation: String, + #[snafu(implicit)] location: Location, }, @@ -642,14 +801,19 @@ pub enum Error { WeightArray { #[snafu(source)] error: WeightedError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Weight array is not set"))] - NotSetWeightArray { location: Location }, + NotSetWeightArray { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unexpected table route type: {}", err_msg))] UnexpectedLogicalRouteTable { + #[snafu(implicit)] location: Location, err_msg: String, source: common_meta::error::Error, @@ -657,12 +821,14 @@ pub enum Error { #[snafu(display("Failed to save cluster info"))] SaveClusterInfo { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Invalid cluster info format"))] InvalidClusterInfoFormat { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, diff --git a/src/metric-engine/src/error.rs b/src/metric-engine/src/error.rs index 81e680dfd060..f52bc6e3cc72 100644 --- a/src/metric-engine/src/error.rs +++ b/src/metric-engine/src/error.rs @@ -27,12 +27,17 @@ use store_api::storage::RegionId; #[stack_trace_debug] pub enum Error { #[snafu(display("Missing internal column {} in physical metric table", column))] - MissingInternalColumn { column: String, location: Location }, + MissingInternalColumn { + column: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to create mito region, region type: {}", region_type))] CreateMitoRegion { region_type: String, source: BoxedError, + #[snafu(implicit)] location: Location, }, @@ -40,6 +45,7 @@ pub enum Error { OpenMitoRegion { region_type: String, source: BoxedError, + #[snafu(implicit)] location: Location, }, @@ -47,12 +53,14 @@ pub enum Error { CloseMitoRegion { region_id: RegionId, source: BoxedError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Region `{}` already exists", region_id))] RegionAlreadyExists { region_id: RegionId, + #[snafu(implicit)] location: Location, }, @@ -61,6 +69,7 @@ pub enum Error { raw: String, #[snafu(source)] error: serde_json::Error, + #[snafu(implicit)] location: Location, }, @@ -69,6 +78,7 @@ pub enum Error { raw: String, #[snafu(source)] error: serde_json::Error, + #[snafu(implicit)] location: Location, }, @@ -76,6 +86,7 @@ pub enum Error { SerializeColumnMetadata { #[snafu(source)] error: serde_json::Error, + #[snafu(implicit)] location: Location, }, @@ -83,6 +94,7 @@ pub enum Error { DecodeColumnValue { #[snafu(source)] error: base64::DecodeError, + #[snafu(implicit)] location: Location, }, @@ -91,45 +103,61 @@ pub enum Error { raw: String, #[snafu(source)] error: ::Err, + #[snafu(implicit)] location: Location, }, #[snafu(display("Mito read operation fails"))] MitoReadOperation { source: BoxedError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Mito write operation fails"))] MitoWriteOperation { source: BoxedError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to collect record batch stream"))] CollectRecordBatchStream { source: common_recordbatch::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Internal column {} is reserved", column))] - InternalColumnOccupied { column: String, location: Location }, + InternalColumnOccupied { + column: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Required table option is missing"))] - MissingRegionOption { location: Location }, + MissingRegionOption { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Region options are conflicted"))] - ConflictRegionOption { location: Location }, + ConflictRegionOption { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Physical region {} not found", region_id))] PhysicalRegionNotFound { region_id: RegionId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Logical region {} not found", region_id))] LogicalRegionNotFound { region_id: RegionId, + #[snafu(implicit)] location: Location, }, @@ -137,6 +165,7 @@ pub enum Error { ColumnTypeMismatch { expect: ConcreteDataType, actual: ConcreteDataType, + #[snafu(implicit)] location: Location, }, @@ -144,15 +173,20 @@ pub enum Error { ColumnNotFound { name: String, region_id: RegionId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Alter request to physical region is forbidden"))] - ForbiddenPhysicalAlter { location: Location }, + ForbiddenPhysicalAlter { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid region metadata"))] InvalidMetadata { source: store_api::metadata::MetadataError, + #[snafu(implicit)] location: Location, }, @@ -162,12 +196,14 @@ pub enum Error { ))] PhysicalRegionBusy { region_id: RegionId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unsupported region request: {}", request))] UnsupportedRegionRequest { request: RegionRequest, + #[snafu(implicit)] location: Location, }, @@ -175,14 +211,22 @@ pub enum Error { MultipleFieldColumn { previous: String, current: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Adding field column {} to physical table", name))] - AddingFieldColumn { name: String, location: Location }, + AddingFieldColumn { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("No field column found"))] - NoFieldColumn { location: Location }, + NoFieldColumn { + #[snafu(implicit)] + location: Location, + }, } pub type Result = std::result::Result; diff --git a/src/mito2/src/error.rs b/src/mito2/src/error.rs index 605b5c6df393..f81052623c43 100644 --- a/src/mito2/src/error.rs +++ b/src/mito2/src/error.rs @@ -42,6 +42,7 @@ pub enum Error { region_id, expected_last_entry_id, replayed_last_entry_id ))] UnexpectedReplay { + #[snafu(implicit)] location: Location, region_id: RegionId, expected_last_entry_id: u64, @@ -50,6 +51,7 @@ pub enum Error { #[snafu(display("OpenDAL operator failed"))] OpenDal { + #[snafu(implicit)] location: Location, #[snafu(source)] error: object_store::Error, @@ -73,6 +75,7 @@ pub enum Error { #[snafu(display("Failed to ser/de json object"))] SerdeJson { + #[snafu(implicit)] location: Location, #[snafu(source)] error: serde_json::Error, @@ -82,47 +85,64 @@ pub enum Error { InvalidScanIndex { start: ManifestVersion, end: ManifestVersion, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid UTF-8 content"))] Utf8 { + #[snafu(implicit)] location: Location, #[snafu(source)] error: std::str::Utf8Error, }, #[snafu(display("Cannot find RegionMetadata"))] - RegionMetadataNotFound { location: Location }, + RegionMetadataNotFound { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to join handle"))] Join { #[snafu(source)] error: common_runtime::JoinError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Worker {} is stopped", id))] - WorkerStopped { id: WorkerId, location: Location }, + WorkerStopped { + id: WorkerId, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to recv result"))] Recv { #[snafu(source)] error: tokio::sync::oneshot::error::RecvError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid metadata, {}", reason))] - InvalidMeta { reason: String, location: Location }, + InvalidMeta { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid region metadata"))] InvalidMetadata { source: store_api::metadata::MetadataError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to create RecordBatch from vectors"))] NewRecordBatch { + #[snafu(implicit)] location: Location, #[snafu(source)] error: ArrowError, @@ -130,6 +150,7 @@ pub enum Error { #[snafu(display("Failed to write to buffer"))] WriteBuffer { + #[snafu(implicit)] location: Location, source: common_datasource::error::Error, }, @@ -139,18 +160,21 @@ pub enum Error { path: String, #[snafu(source)] error: parquet::errors::ParquetError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Region {} not found", region_id))] RegionNotFound { region_id: RegionId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Object store not found: {}", object_store))] ObjectStoreNotFound { object_store: String, + #[snafu(implicit)] location: Location, }, @@ -158,6 +182,7 @@ pub enum Error { RegionCorrupted { region_id: RegionId, reason: String, + #[snafu(implicit)] location: Location, }, @@ -165,6 +190,7 @@ pub enum Error { InvalidRequest { region_id: RegionId, reason: String, + #[snafu(implicit)] location: Location, }, @@ -175,6 +201,7 @@ pub enum Error { ConvertColumnDataType { reason: String, source: api::error::Error, + #[snafu(implicit)] location: Location, }, @@ -200,6 +227,7 @@ pub enum Error { #[snafu(display("Failed to encode WAL entry, region_id: {}", region_id))] EncodeWal { region_id: RegionId, + #[snafu(implicit)] location: Location, #[snafu(source)] error: EncodeError, @@ -207,6 +235,7 @@ pub enum Error { #[snafu(display("Failed to write WAL"))] WriteWal { + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -214,6 +243,7 @@ pub enum Error { #[snafu(display("Failed to read WAL, region_id: {}", region_id))] ReadWal { region_id: RegionId, + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -221,6 +251,7 @@ pub enum Error { #[snafu(display("Failed to decode WAL entry, region_id: {}", region_id))] DecodeWal { region_id: RegionId, + #[snafu(implicit)] location: Location, #[snafu(source)] error: DecodeError, @@ -229,6 +260,7 @@ pub enum Error { #[snafu(display("Failed to delete WAL, region_id: {}", region_id))] DeleteWal { region_id: RegionId, + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -244,6 +276,7 @@ pub enum Error { SerializeField { #[snafu(source)] error: memcomparable::Error, + #[snafu(implicit)] location: Location, }, @@ -253,6 +286,7 @@ pub enum Error { ))] NotSupportedField { data_type: ConcreteDataType, + #[snafu(implicit)] location: Location, }, @@ -260,6 +294,7 @@ pub enum Error { DeserializeField { #[snafu(source)] error: memcomparable::Error, + #[snafu(implicit)] location: Location, }, @@ -267,23 +302,34 @@ pub enum Error { InvalidParquet { file: String, reason: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid batch, {}", reason))] - InvalidBatch { reason: String, location: Location }, + InvalidBatch { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid arrow record batch, {}", reason))] - InvalidRecordBatch { reason: String, location: Location }, + InvalidRecordBatch { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to convert array to vector"))] ConvertVector { + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, #[snafu(display("Failed to compute arrow arrays"))] ComputeArrow { + #[snafu(implicit)] location: Location, #[snafu(source)] error: datatypes::arrow::error::ArrowError, @@ -291,6 +337,7 @@ pub enum Error { #[snafu(display("Failed to compute vector"))] ComputeVector { + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, @@ -299,19 +346,27 @@ pub enum Error { PrimaryKeyLengthMismatch { expect: usize, actual: usize, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid sender",))] - InvalidSender { location: Location }, + InvalidSender { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid scheduler state"))] - InvalidSchedulerState { location: Location }, + InvalidSchedulerState { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to stop scheduler"))] StopScheduler { #[snafu(source)] error: JoinError, + #[snafu(implicit)] location: Location, }, @@ -320,6 +375,7 @@ pub enum Error { file_id: FileId, #[snafu(source)] error: object_store::Error, + #[snafu(implicit)] location: Location, }, @@ -328,6 +384,7 @@ pub enum Error { file_id: FileId, #[snafu(source)] error: object_store::Error, + #[snafu(implicit)] location: Location, }, @@ -335,24 +392,28 @@ pub enum Error { FlushRegion { region_id: RegionId, source: Arc, + #[snafu(implicit)] location: Location, }, #[snafu(display("Region {} is dropped", region_id))] RegionDropped { region_id: RegionId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Region {} is closed", region_id))] RegionClosed { region_id: RegionId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Region {} is truncated", region_id))] RegionTruncated { region_id: RegionId, + #[snafu(implicit)] location: Location, }, @@ -362,6 +423,7 @@ pub enum Error { ))] RejectWrite { region_id: RegionId, + #[snafu(implicit)] location: Location, }, @@ -369,6 +431,7 @@ pub enum Error { CompactRegion { region_id: RegionId, source: Arc, + #[snafu(implicit)] location: Location, }, @@ -380,12 +443,14 @@ pub enum Error { CompatReader { region_id: RegionId, reason: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalue region req"))] InvalidRegionRequest { source: store_api::metadata::MetadataError, + #[snafu(implicit)] location: Location, }, @@ -393,6 +458,7 @@ pub enum Error { InvalidRegionRequestSchemaVersion { expect: u64, actual: u64, + #[snafu(implicit)] location: Location, }, @@ -401,6 +467,7 @@ pub enum Error { region_id: RegionId, state: RegionState, expect: RegionState, + #[snafu(implicit)] location: Location, }, @@ -408,6 +475,7 @@ pub enum Error { JsonOptions { #[snafu(source)] error: serde_json::Error, + #[snafu(implicit)] location: Location, }, @@ -419,12 +487,14 @@ pub enum Error { EmptyRegionDir { region_id: RegionId, region_dir: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Empty manifest directory, manifest_dir: {}", manifest_dir,))] EmptyManifestDir { manifest_dir: String, + #[snafu(implicit)] location: Location, }, @@ -433,79 +503,98 @@ pub enum Error { path: String, #[snafu(source)] error: ArrowError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid file metadata"))] ConvertMetaData { + #[snafu(implicit)] location: Location, #[snafu(source)] error: parquet::errors::ParquetError, }, #[snafu(display("Column not found, column: {column}"))] - ColumnNotFound { column: String, location: Location }, + ColumnNotFound { + column: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to build index applier"))] BuildIndexApplier { source: index::inverted_index::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to convert value"))] ConvertValue { source: datatypes::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to apply index"))] ApplyIndex { source: index::inverted_index::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to push index value"))] PushIndexValue { source: index::inverted_index::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to write index completely"))] IndexFinish { source: index::inverted_index::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Operate on aborted index"))] - OperateAbortedIndex { location: Location }, + OperateAbortedIndex { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to read puffin metadata"))] PuffinReadMetadata { source: puffin::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to read puffin blob"))] PuffinReadBlob { source: puffin::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Blob type not found, blob_type: {blob_type}"))] PuffinBlobTypeNotFound { blob_type: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to write puffin completely"))] PuffinFinish { source: puffin::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to add blob to puffin file"))] PuffinAddBlob { source: puffin::error::Error, + #[snafu(implicit)] location: Location, }, @@ -514,11 +603,16 @@ pub enum Error { dir: String, #[snafu(source)] error: std::io::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid config, {reason}"))] - InvalidConfig { reason: String, location: Location }, + InvalidConfig { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Stale log entry found during replay, region: {}, flushed: {}, replayed: {}", @@ -544,12 +638,14 @@ pub enum Error { file_type: FileType, #[snafu(source)] error: std::io::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to filter record batch"))] FilterRecordBatch { source: common_recordbatch::error::Error, + #[snafu(implicit)] location: Location, }, @@ -557,16 +653,21 @@ pub enum Error { BiError { first: Box, second: Box, + #[snafu(implicit)] location: Location, }, #[snafu(display("Encode null value"))] - IndexEncodeNull { location: Location }, + IndexEncodeNull { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to encode memtable to Parquet bytes"))] EncodeMemtable { #[snafu(source)] error: parquet::errors::ParquetError, + #[snafu(implicit)] location: Location, }, @@ -577,7 +678,11 @@ pub enum Error { }, #[snafu(display("Invalid region options, {}", reason))] - InvalidRegionOptions { reason: String, location: Location }, + InvalidRegionOptions { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("checksum mismatch (actual: {}, expected: {})", actual, expected))] ChecksumMismatch { actual: u32, expected: u32 }, @@ -585,6 +690,7 @@ pub enum Error { #[snafu(display("Region {} is stopped", region_id))] RegionStopped { region_id: RegionId, + #[snafu(implicit)] location: Location, }, } diff --git a/src/operator/src/error.rs b/src/operator/src/error.rs index 344a6c9ec4ff..8564ceefe815 100644 --- a/src/operator/src/error.rs +++ b/src/operator/src/error.rs @@ -29,16 +29,22 @@ use sql::ast::Value; #[stack_trace_debug] pub enum Error { #[snafu(display("Table already exists: `{}`", table))] - TableAlreadyExists { table: String, location: Location }, + TableAlreadyExists { + table: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to invalidate table cache"))] InvalidateTableCache { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to execute ddl"))] ExecuteDdl { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, @@ -46,38 +52,47 @@ pub enum Error { #[snafu(display("Unexpected, violated: {}", violated))] Unexpected { violated: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("external error"))] External { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Failed to insert data"))] RequestInserts { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to delete data"))] RequestDeletes { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Failed to send request to region"))] RequestRegion { + #[snafu(implicit)] location: Location, source: common_meta::error::Error, }, #[snafu(display("Unsupported region request"))] - UnsupportedRegionRequest { location: Location }, + UnsupportedRegionRequest { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to parse SQL"))] ParseSql { + #[snafu(implicit)] location: Location, source: sql::error::Error, }, @@ -85,6 +100,7 @@ pub enum Error { #[snafu(display("Failed to convert identifier: {}", ident))] ConvertIdentifier { ident: String, + #[snafu(implicit)] location: Location, #[snafu(source)] error: datafusion::error::DataFusionError, @@ -93,12 +109,14 @@ pub enum Error { #[snafu(display("Failed to convert value to sql value: {}", value))] ConvertSqlValue { value: Value, + #[snafu(implicit)] location: Location, source: sql::error::Error, }, #[snafu(display("Column datatype error"))] ColumnDataType { + #[snafu(implicit)] location: Location, source: api::error::Error, }, @@ -106,6 +124,7 @@ pub enum Error { #[snafu(display("Invalid column proto definition, column: {}", column))] InvalidColumnDef { column: String, + #[snafu(implicit)] location: Location, source: api::error::Error, }, @@ -113,18 +132,31 @@ pub enum Error { #[snafu(display("Failed to convert column default constraint, column: {}", column_name))] ConvertColumnDefaultConstraint { column_name: String, + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, #[snafu(display("Invalid SQL, error: {}", err_msg))] - InvalidSql { err_msg: String, location: Location }, + InvalidSql { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid InsertRequest, reason: {}", reason))] - InvalidInsertRequest { reason: String, location: Location }, + InvalidInsertRequest { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid DeleteRequest, reason: {}", reason))] - InvalidDeleteRequest { reason: String, location: Location }, + InvalidDeleteRequest { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Table not found: {}", table_name))] TableNotFound { table_name: String }, @@ -136,11 +168,13 @@ pub enum Error { JoinTask { #[snafu(source)] error: common_runtime::JoinError, + #[snafu(implicit)] location: Location, }, #[snafu(display("General catalog error"))] Catalog { + #[snafu(implicit)] location: Location, source: catalog::error::Error, }, @@ -148,6 +182,7 @@ pub enum Error { #[snafu(display("Failed to find table partition rule for table {}", table_name))] FindTablePartitionRule { table_name: String, + #[snafu(implicit)] location: Location, source: partition::error::Error, }, @@ -155,29 +190,34 @@ pub enum Error { #[snafu(display("Failed to split insert request"))] SplitInsert { source: partition::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to split delete request"))] SplitDelete { source: partition::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to find leader for region"))] FindRegionLeader { source: partition::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to create table info"))] CreateTableInfo { + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, #[snafu(display("Failed to build CreateExpr on insertion"))] BuildCreateExprOnInsertion { + #[snafu(implicit)] location: Location, source: common_grpc_expr::error::Error, }, @@ -185,41 +225,55 @@ pub enum Error { #[snafu(display("Failed to find schema, schema info: {}", schema_info))] SchemaNotFound { schema_info: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Schema {} already exists", name))] - SchemaExists { name: String, location: Location }, + SchemaExists { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Table occurs error"))] Table { + #[snafu(implicit)] location: Location, source: table::error::Error, }, #[snafu(display("Cannot find column by name: {}", msg))] - ColumnNotFound { msg: String, location: Location }, + ColumnNotFound { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to execute statement"))] ExecuteStatement { + #[snafu(implicit)] location: Location, source: query::error::Error, }, #[snafu(display("Failed to plan statement"))] PlanStatement { + #[snafu(implicit)] location: Location, source: query::error::Error, }, #[snafu(display("Failed to parse query"))] ParseQuery { + #[snafu(implicit)] location: Location, source: query::error::Error, }, #[snafu(display("Failed to execute logical plan"))] ExecLogicalPlan { + #[snafu(implicit)] location: Location, source: query::error::Error, }, @@ -228,11 +282,13 @@ pub enum Error { BuildDfLogicalPlan { #[snafu(source)] error: datafusion_common::DataFusionError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to convert AlterExpr to AlterRequest"))] AlterExprToRequest { + #[snafu(implicit)] location: Location, source: common_grpc_expr::error::Error, }, @@ -242,6 +298,7 @@ pub enum Error { table_name: String, #[snafu(source)] error: table::metadata::TableMetaBuilderError, + #[snafu(implicit)] location: Location, }, @@ -250,45 +307,56 @@ pub enum Error { #[snafu(display("Failed to find new columns on insertion"))] FindNewColumnsOnInsertion { + #[snafu(implicit)] location: Location, source: common_grpc_expr::error::Error, }, #[snafu(display("Failed to convert into vectors"))] IntoVectors { + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, #[snafu(display("Failed to deserialize partition in meta to partition def"))] DeserializePartition { + #[snafu(implicit)] location: Location, source: partition::error::Error, }, #[snafu(display("Failed to describe schema for given statement"))] DescribeStatement { + #[snafu(implicit)] location: Location, source: query::error::Error, }, #[snafu(display("Illegal primary keys definition: {}", msg))] - IllegalPrimaryKeysDef { msg: String, location: Location }, + IllegalPrimaryKeysDef { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unrecognized table option"))] UnrecognizedTableOption { + #[snafu(implicit)] location: Location, source: table::error::Error, }, #[snafu(display("Missing time index column"))] MissingTimeIndexColumn { + #[snafu(implicit)] location: Location, source: table::error::Error, }, #[snafu(display("Failed to build regex"))] BuildRegex { + #[snafu(implicit)] location: Location, #[snafu(source)] error: regex::Error, @@ -297,6 +365,7 @@ pub enum Error { #[snafu(display("Failed to copy table: {}", table_name))] CopyTable { table_name: String, + #[snafu(implicit)] location: Location, source: table::error::Error, }, @@ -304,33 +373,42 @@ pub enum Error { #[snafu(display("Failed to insert value into table: {}", table_name))] Insert { table_name: String, + #[snafu(implicit)] location: Location, source: table::error::Error, }, #[snafu(display("Failed to parse data source url"))] ParseUrl { + #[snafu(implicit)] location: Location, source: common_datasource::error::Error, }, #[snafu(display("Unsupported format: {:?}", format))] - UnsupportedFormat { location: Location, format: Format }, + UnsupportedFormat { + #[snafu(implicit)] + location: Location, + format: Format, + }, #[snafu(display("Failed to parse file format"))] ParseFileFormat { + #[snafu(implicit)] location: Location, source: common_datasource::error::Error, }, #[snafu(display("Failed to build data source backend"))] BuildBackend { + #[snafu(implicit)] location: Location, source: common_datasource::error::Error, }, #[snafu(display("Failed to list objects"))] ListObjects { + #[snafu(implicit)] location: Location, source: common_datasource::error::Error, }, @@ -338,6 +416,7 @@ pub enum Error { #[snafu(display("Failed to infer schema from path: {}", path))] InferSchema { path: String, + #[snafu(implicit)] location: Location, source: common_datasource::error::Error, }, @@ -346,12 +425,14 @@ pub enum Error { BuildCsvConfig { #[snafu(source)] error: common_datasource::file_format::csv::CsvConfigBuilderError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to write stream to path: {}", path))] WriteStreamToFile { path: String, + #[snafu(implicit)] location: Location, source: common_datasource::error::Error, }, @@ -359,6 +440,7 @@ pub enum Error { #[snafu(display("Failed to read object in path: {}", path))] ReadObject { path: String, + #[snafu(implicit)] location: Location, #[snafu(source)] error: object_store::Error, @@ -368,6 +450,7 @@ pub enum Error { ReadDfRecordBatch { #[snafu(source)] error: datafusion::error::DataFusionError, + #[snafu(implicit)] location: Location, }, @@ -375,17 +458,20 @@ pub enum Error { ReadParquetMetadata { #[snafu(source)] error: parquet::errors::ParquetError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to read orc schema"))] ReadOrc { source: common_datasource::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to build parquet record batch stream"))] BuildParquetRecordBatchStream { + #[snafu(implicit)] location: Location, #[snafu(source)] error: parquet::errors::ParquetError, @@ -393,6 +479,7 @@ pub enum Error { #[snafu(display("Failed to build file stream"))] BuildFileStream { + #[snafu(implicit)] location: Location, #[snafu(source)] error: datafusion::error::DataFusionError, @@ -408,6 +495,7 @@ pub enum Error { index: usize, table_schema: String, file_schema: String, + #[snafu(implicit)] location: Location, }, @@ -415,6 +503,7 @@ pub enum Error { ProjectSchema { #[snafu(source)] error: ArrowError, + #[snafu(implicit)] location: Location, }, @@ -422,11 +511,13 @@ pub enum Error { EncodeJson { #[snafu(source)] error: serde_json::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to prepare immutable table"))] PrepareImmutableTable { + #[snafu(implicit)] location: Location, source: query::error::Error, }, @@ -435,45 +526,56 @@ pub enum Error { InvalidCopyParameter { key: String, value: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid COPY DATABASE location, must end with '/': {}", value))] - InvalidCopyDatabasePath { value: String, location: Location }, + InvalidCopyDatabasePath { + value: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Table metadata manager error"))] TableMetadataManager { source: common_meta::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to read record batch"))] ReadRecordBatch { source: common_recordbatch::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to build column vectors"))] BuildColumnVectors { source: common_recordbatch::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Missing insert body"))] MissingInsertBody { source: sql::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to parse sql value"))] ParseSqlValue { source: sql::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to build default value, column: {}", column))] ColumnDefaultValue { column: String, + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, @@ -482,7 +584,11 @@ pub enum Error { "No valid default value can be built automatically, column: {}", column, ))] - ColumnNoneDefaultValue { column: String, location: Location }, + ColumnNoneDefaultValue { + column: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Invalid partition columns when creating table '{}', reason: {}", @@ -492,23 +598,27 @@ pub enum Error { InvalidPartitionColumns { table: String, reason: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to prepare file table"))] PrepareFileTable { + #[snafu(implicit)] location: Location, source: query::error::Error, }, #[snafu(display("Failed to infer file table schema"))] InferFileTableSchema { + #[snafu(implicit)] location: Location, source: query::error::Error, }, #[snafu(display("The schema of the file table is incompatible with the table schema"))] SchemaIncompatible { + #[snafu(implicit)] location: Location, source: query::error::Error, }, @@ -516,33 +626,49 @@ pub enum Error { #[snafu(display("Invalid table name: {}", table_name))] InvalidTableName { table_name: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Do not support {} in multiple catalogs", ddl_name))] DdlWithMultiCatalogs { ddl_name: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Do not support {} in multiple schemas", ddl_name))] DdlWithMultiSchemas { ddl_name: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Empty {} expr", name))] - EmptyDdlExpr { name: String, location: Location }, + EmptyDdlExpr { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to create logical tables: {}", reason))] - CreateLogicalTables { reason: String, location: Location }, + CreateLogicalTables { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid partition rule: {}", reason))] - InvalidPartitionRule { reason: String, location: Location }, + InvalidPartitionRule { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid configuration value."))] InvalidConfigValue { source: session::session_config::Error, + #[snafu(implicit)] location: Location, }, @@ -550,6 +676,7 @@ pub enum Error { InvalidTimestampRange { start: String, end: String, + #[snafu(implicit)] location: Location, }, } diff --git a/src/partition/src/error.rs b/src/partition/src/error.rs index ed4ba151e6fd..921c29429f1c 100644 --- a/src/partition/src/error.rs +++ b/src/partition/src/error.rs @@ -32,22 +32,29 @@ pub enum Error { #[snafu(display("Table route manager error"))] TableRouteManager { source: common_meta::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to get meta info from cache, error: {}", err_msg))] - GetCache { err_msg: String, location: Location }, + GetCache { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to find Datanode, table id: {}, region: {}", table_id, region))] FindDatanode { table_id: TableId, region: RegionNumber, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to find table routes for table id {}", table_id))] FindTableRoutes { table_id: TableId, + #[snafu(implicit)] location: Location, }, @@ -59,6 +66,7 @@ pub enum Error { FindRegionRoutes { table_id: TableId, region_id: u64, + #[snafu(implicit)] location: Location, }, @@ -66,6 +74,7 @@ pub enum Error { SerializeJson { #[snafu(source)] error: serde_json::Error, + #[snafu(implicit)] location: Location, }, @@ -73,6 +82,7 @@ pub enum Error { DeserializeJson { #[snafu(source)] error: serde_json::Error, + #[snafu(implicit)] location: Location, }, @@ -83,34 +93,50 @@ pub enum Error { RegionKeysSize { expect: usize, actual: usize, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to find region, reason: {}", reason))] - FindRegion { reason: String, location: Location }, + FindRegion { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to find regions by filters: {:?}", filters))] FindRegions { filters: Vec, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid InsertRequest, reason: {}", reason))] - InvalidInsertRequest { reason: String, location: Location }, + InvalidInsertRequest { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid DeleteRequest, reason: {}", reason))] - InvalidDeleteRequest { reason: String, location: Location }, + InvalidDeleteRequest { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid table route data, table id: {}, msg: {}", table_id, err_msg))] InvalidTableRouteData { table_id: TableId, err_msg: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to convert DataFusion's ScalarValue: {:?}", value))] ConvertScalarValue { value: ScalarValue, + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, @@ -119,11 +145,13 @@ pub enum Error { FindLeader { table_id: TableId, region_id: RegionId, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unexpected table route type: {}", err_msg))] UnexpectedLogicalRouteTable { + #[snafu(implicit)] location: Location, err_msg: String, source: common_meta::error::Error, @@ -132,6 +160,7 @@ pub enum Error { #[snafu(display("Conjunct expr with non-expr is invalid"))] ConjunctExprWithNonExpr { expr: PartitionExpr, + #[snafu(implicit)] location: Location, }, @@ -139,17 +168,23 @@ pub enum Error { UnclosedValue { value: String, column: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid partition expr: {:?}", expr))] InvalidExpr { expr: PartitionExpr, + #[snafu(implicit)] location: Location, }, #[snafu(display("Undefined column: {}", column))] - UndefinedColumn { column: String, location: Location }, + UndefinedColumn { + column: String, + #[snafu(implicit)] + location: Location, + }, } impl ErrorExt for Error { diff --git a/src/promql/src/error.rs b/src/promql/src/error.rs index 65b14c2d7bb5..4cc4c47a2e75 100644 --- a/src/promql/src/error.rs +++ b/src/promql/src/error.rs @@ -26,17 +26,23 @@ use snafu::{Location, Snafu}; #[stack_trace_debug] pub enum Error { #[snafu(display("Unsupported expr type: {}", name))] - UnsupportedExpr { name: String, location: Location }, + UnsupportedExpr { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unsupported vector matches: {:?}", name))] UnsupportedVectorMatch { name: VectorMatchCardinality, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unexpected token: {:?}", token))] UnexpectedToken { token: TokenType, + #[snafu(implicit)] location: Location, }, @@ -44,29 +50,53 @@ pub enum Error { DataFusionPlanning { #[snafu(source)] error: datafusion::error::DataFusionError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unexpected plan or expression: {}", desc))] - UnexpectedPlanExpr { desc: String, location: Location }, + UnexpectedPlanExpr { + desc: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unknown table type, downcast failed"))] - UnknownTable { location: Location }, + UnknownTable { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Cannot find time index column in table {}", table))] - TimeIndexNotFound { table: String, location: Location }, + TimeIndexNotFound { + table: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Cannot find value columns in table {}", table))] - ValueNotFound { table: String, location: Location }, + ValueNotFound { + table: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Cannot accept multiple vector as function input, PromQL expr: {:?}", expr, ))] - MultipleVector { expr: PromExpr, location: Location }, + MultipleVector { + expr: PromExpr, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Expect a PromQL expr but not found, input expr: {:?}", expr))] - ExpectExpr { expr: PromExpr, location: Location }, + ExpectExpr { + expr: PromExpr, + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Illegal range: offset {}, length {}, array len {}", offset, @@ -77,6 +107,7 @@ pub enum Error { offset: u32, length: u32, len: usize, + #[snafu(implicit)] location: Location, }, @@ -84,40 +115,68 @@ pub enum Error { Deserialize { #[snafu(source)] error: prost::DecodeError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Empty range is not expected"))] - EmptyRange { location: Location }, + EmptyRange { + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Table (metric) name not found, this indicates a procedure error in PromQL planner" ))] - TableNameNotFound { location: Location }, + TableNameNotFound { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("General catalog error: "))] Catalog { + #[snafu(implicit)] location: Location, source: catalog::error::Error, }, #[snafu(display("Expect a range selector, but not found"))] - ExpectRangeSelector { location: Location }, + ExpectRangeSelector { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Zero range in range selector"))] - ZeroRangeSelector { location: Location }, + ZeroRangeSelector { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Cannot find column {col}"))] - ColumnNotFound { col: String, location: Location }, + ColumnNotFound { + col: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Found multiple metric matchers in selector"))] - MultipleMetricMatchers { location: Location }, + MultipleMetricMatchers { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Expect a metric matcher, but not found"))] - NoMetricMatcher { location: Location }, + NoMetricMatcher { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid function argument for {}", fn_name))] - FunctionInvalidArgument { fn_name: String, location: Location }, + FunctionInvalidArgument { + fn_name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Attempt to combine two tables with different column sets, left: {:?}, right: {:?}", @@ -127,12 +186,14 @@ pub enum Error { CombineTableColumnMismatch { left: Vec, right: Vec, + #[snafu(implicit)] location: Location, }, #[snafu(display("Multi fields calculation is not supported in {}", operator))] MultiFieldsNotSupported { operator: String, + #[snafu(implicit)] location: Location, }, @@ -140,6 +201,7 @@ pub enum Error { UnsupportedMatcherOp { matcher_op: String, matcher: String, + #[snafu(implicit)] location: Location, }, } diff --git a/src/puffin/src/error.rs b/src/puffin/src/error.rs index 8aa5e9dfbfae..34b76ef5210f 100644 --- a/src/puffin/src/error.rs +++ b/src/puffin/src/error.rs @@ -28,6 +28,7 @@ pub enum Error { Seek { #[snafu(source)] error: IoError, + #[snafu(implicit)] location: Location, }, @@ -35,6 +36,7 @@ pub enum Error { Read { #[snafu(source)] error: IoError, + #[snafu(implicit)] location: Location, }, @@ -42,6 +44,7 @@ pub enum Error { Write { #[snafu(source)] error: IoError, + #[snafu(implicit)] location: Location, }, @@ -49,6 +52,7 @@ pub enum Error { Flush { #[snafu(source)] error: IoError, + #[snafu(implicit)] location: Location, }, @@ -56,22 +60,28 @@ pub enum Error { Close { #[snafu(source)] error: IoError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Magic not matched"))] - MagicNotMatched { location: Location }, + MagicNotMatched { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to convert bytes to integer"))] BytesToInteger { #[snafu(source)] error: std::array::TryFromSliceError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unsupported decompression: {}", decompression))] UnsupportedDecompression { decompression: String, + #[snafu(implicit)] location: Location, }, @@ -79,6 +89,7 @@ pub enum Error { SerializeJson { #[snafu(source)] error: serde_json::Error, + #[snafu(implicit)] location: Location, }, @@ -86,6 +97,7 @@ pub enum Error { DeserializeJson { #[snafu(source)] error: serde_json::Error, + #[snafu(implicit)] location: Location, }, @@ -93,11 +105,16 @@ pub enum Error { ParseStageNotMatch { expected: String, actual: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unexpected footer payload size: {}", size))] - UnexpectedFooterPayloadSize { size: i32, location: Location }, + UnexpectedFooterPayloadSize { + size: i32, + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Unexpected puffin file size, min: {}, actual: {}", @@ -107,14 +124,23 @@ pub enum Error { UnexpectedPuffinFileSize { min_file_size: u64, actual_file_size: u64, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid blob offset: {}, location: {:?}", offset, location))] - InvalidBlobOffset { offset: i64, location: Location }, + InvalidBlobOffset { + offset: i64, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid blob area end: {}, location: {:?}", offset, location))] - InvalidBlobAreaEnd { offset: u64, location: Location }, + InvalidBlobAreaEnd { + offset: u64, + #[snafu(implicit)] + location: Location, + }, } impl ErrorExt for Error { diff --git a/src/query/src/datafusion/error.rs b/src/query/src/datafusion/error.rs index 9d52c8fa9d97..6d97a162be3e 100644 --- a/src/query/src/datafusion/error.rs +++ b/src/query/src/datafusion/error.rs @@ -29,26 +29,33 @@ pub enum InnerError { Datafusion { #[snafu(source)] error: DataFusionError, + #[snafu(implicit)] location: Location, }, #[snafu(display("PhysicalPlan downcast failed"))] - PhysicalPlanDowncast { location: Location }, + PhysicalPlanDowncast { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Fail to convert arrow schema"))] ConvertSchema { + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, #[snafu(display("Failed to convert DataFusion's recordbatch stream"))] ConvertDfRecordBatchStream { + #[snafu(implicit)] location: Location, source: common_recordbatch::error::Error, }, #[snafu(display("Failed to execute physical plan"))] ExecutePhysicalPlan { + #[snafu(implicit)] location: Location, source: common_query::error::Error, }, diff --git a/src/query/src/error.rs b/src/query/src/error.rs index bb3bc0ff4b97..7c0160d96042 100644 --- a/src/query/src/error.rs +++ b/src/query/src/error.rs @@ -29,47 +29,72 @@ use store_api::storage::RegionId; #[stack_trace_debug] pub enum Error { #[snafu(display("Unsupported expr type: {}", name))] - UnsupportedExpr { name: String, location: Location }, + UnsupportedExpr { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unsupported show variable: {}", name))] - UnsupportedVariable { name: String, location: Location }, + UnsupportedVariable { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Operation {} not implemented yet", operation))] Unimplemented { operation: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("General catalog error"))] Catalog { source: catalog::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Catalog not found: {}", catalog))] - CatalogNotFound { catalog: String, location: Location }, + CatalogNotFound { + catalog: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Schema not found: {}", schema))] - SchemaNotFound { schema: String, location: Location }, + SchemaNotFound { + schema: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Table not found: {}", table))] - TableNotFound { table: String, location: Location }, + TableNotFound { + table: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to create RecordBatch"))] CreateRecordBatch { source: common_recordbatch::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failure during query execution"))] QueryExecution { source: BoxedError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failure during query planning"))] QueryPlan { source: BoxedError, + #[snafu(implicit)] location: Location, }, @@ -77,6 +102,7 @@ pub enum Error { QueryParse { query: String, source: BoxedError, + #[snafu(implicit)] location: Location, }, @@ -84,15 +110,21 @@ pub enum Error { QueryAccessDenied { catalog: String, schema: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("The SQL string has multiple statements, query: {}", query))] - MultipleStatements { query: String, location: Location }, + MultipleStatements { + query: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to convert Datafusion schema"))] ConvertDatafusionSchema { source: datatypes::error::Error, + #[snafu(implicit)] location: Location, }, @@ -101,17 +133,23 @@ pub enum Error { raw: String, #[snafu(source)] error: chrono::ParseError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid timestamp `{}`", raw))] - InvalidTimestamp { raw: String, location: Location }, + InvalidTimestamp { + raw: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to parse float number `{}`", raw))] ParseFloat { raw: String, #[snafu(source)] error: std::num::ParseFloatError, + #[snafu(implicit)] location: Location, }, @@ -119,17 +157,20 @@ pub enum Error { DataFusion { #[snafu(source)] error: DataFusionError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to encode Substrait logical plan"))] EncodeSubstraitLogicalPlan { source: substrait::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("General SQL error"))] Sql { + #[snafu(implicit)] location: Location, source: sql::error::Error, }, @@ -138,12 +179,14 @@ pub enum Error { PlanSql { #[snafu(source)] error: DataFusionError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Timestamp column for table '{table_name}' is missing!"))] MissingTimestampColumn { table_name: String, + #[snafu(implicit)] location: Location, }, @@ -151,6 +194,7 @@ pub enum Error { ConvertSqlValue { value: Value, source: sql::error::Error, + #[snafu(implicit)] location: Location, }, @@ -158,14 +202,20 @@ pub enum Error { ConvertSqlType { datatype: ConcreteDataType, source: sql::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Missing required field: {}", name))] - MissingRequiredField { name: String, location: Location }, + MissingRequiredField { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to regex"))] BuildRegex { + #[snafu(implicit)] location: Location, #[snafu(source)] error: regex::Error, @@ -174,41 +224,54 @@ pub enum Error { #[snafu(display("Failed to build data source backend"))] BuildBackend { source: common_datasource::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to list objects"))] ListObjects { source: common_datasource::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to parse file format"))] ParseFileFormat { source: common_datasource::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to infer schema"))] InferSchema { source: common_datasource::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to convert datafusion schema"))] ConvertSchema { source: datatypes::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unknown table type, downcast failed"))] - UnknownTable { location: Location }, + UnknownTable { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Cannot find time index column in table {}", table))] - TimeIndexNotFound { table: String, location: Location }, + TimeIndexNotFound { + table: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to add duration '{:?}' to SystemTime, overflowed", duration))] AddSystemTimeOverflow { duration: Duration, + #[snafu(implicit)] location: Location, }, @@ -222,29 +285,43 @@ pub enum Error { column: String, file_type: ConcreteDataType, table_type: ConcreteDataType, + #[snafu(implicit)] location: Location, }, #[snafu(display("Column schema has no default value, column: {}", column))] - ColumnSchemaNoDefault { column: String, location: Location }, + ColumnSchemaNoDefault { + column: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Region query error"))] RegionQuery { source: BoxedError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Table mutation error"))] TableMutation { source: common_query::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Missing table mutation handler"))] - MissingTableMutationHandler { location: Location }, + MissingTableMutationHandler { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Range Query: {}", msg))] - RangeQuery { msg: String, location: Location }, + RangeQuery { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Failed to get metadata from engine {} for region_id {}", @@ -254,6 +331,7 @@ pub enum Error { GetRegionMetadata { engine: String, region_id: RegionId, + #[snafu(implicit)] location: Location, source: BoxedError, }, diff --git a/src/script/src/error.rs b/src/script/src/error.rs index 40ac698b6a1a..ff6d272e051e 100644 --- a/src/script/src/error.rs +++ b/src/script/src/error.rs @@ -24,14 +24,22 @@ use snafu::{Location, Snafu}; #[stack_trace_debug] pub enum Error { #[snafu(display("Failed to find column in scripts table, name: {}", name))] - FindColumnInScriptsTable { name: String, location: Location }, + FindColumnInScriptsTable { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Scripts table not found"))] - ScriptsTableNotFound { location: Location }, + ScriptsTableNotFound { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to insert script to scripts table, name: {}", name))] InsertScript { name: String, + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -39,6 +47,7 @@ pub enum Error { #[snafu(display("Failed to compile python script, name: {}", name))] CompilePython { name: String, + #[snafu(implicit)] location: Location, source: crate::python::error::Error, }, @@ -46,32 +55,44 @@ pub enum Error { #[snafu(display("Failed to execute python script {}", name))] ExecutePython { name: String, + #[snafu(implicit)] location: Location, source: crate::python::error::Error, }, #[snafu(display("Script not found, name: {}", name))] - ScriptNotFound { location: Location, name: String }, + ScriptNotFound { + #[snafu(implicit)] + location: Location, + name: String, + }, #[snafu(display("Failed to collect record batch"))] CollectRecords { + #[snafu(implicit)] location: Location, source: common_recordbatch::error::Error, }, #[snafu(display("Failed to cast type, msg: {}", msg))] - CastType { msg: String, location: Location }, + CastType { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to build DataFusion logical plan"))] BuildDfLogicalPlan { #[snafu(source)] error: datafusion_common::DataFusionError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to execute internal statement"))] ExecuteInternalStatement { source: query::error::Error, + #[snafu(implicit)] location: Location, }, } diff --git a/src/script/src/python/error.rs b/src/script/src/python/error.rs index ad00998f3a4c..766d61ccc0f0 100644 --- a/src/script/src/python/error.rs +++ b/src/script/src/python/error.rs @@ -38,18 +38,21 @@ pub(crate) fn ret_other_error_with(reason: String) -> OtherSnafu { pub enum Error { #[snafu(display("Datatype error"))] TypeCast { + #[snafu(implicit)] location: SnafuLocation, source: DataTypeError, }, #[snafu(display("Failed to query"))] DatabaseQuery { + #[snafu(implicit)] location: SnafuLocation, source: QueryError, }, #[snafu(display("Failed to parse script"))] PyParse { + #[snafu(implicit)] location: SnafuLocation, #[snafu(source)] error: ParseError, @@ -57,6 +60,7 @@ pub enum Error { #[snafu(display("Failed to compile script"))] PyCompile { + #[snafu(implicit)] location: SnafuLocation, #[snafu(source)] error: CodegenError, @@ -66,11 +70,13 @@ pub enum Error { #[snafu(display("Python Runtime error, error: {}", msg))] PyRuntime { msg: String, + #[snafu(implicit)] location: SnafuLocation, }, #[snafu(display("Arrow error"))] Arrow { + #[snafu(implicit)] location: SnafuLocation, #[snafu(source)] error: ArrowError, @@ -78,6 +84,7 @@ pub enum Error { #[snafu(display("DataFusion error"))] DataFusion { + #[snafu(implicit)] location: SnafuLocation, #[snafu(source)] error: DataFusionError, @@ -91,6 +98,7 @@ pub enum Error { "".into() }))] CoprParse { + #[snafu(implicit)] location: SnafuLocation, reason: String, // location is option because maybe errors can't give a clear location? @@ -100,6 +108,7 @@ pub enum Error { /// Other types of error that isn't any of above #[snafu(display("Coprocessor's Internal error: {}", reason))] Other { + #[snafu(implicit)] location: SnafuLocation, reason: String, }, @@ -107,17 +116,20 @@ pub enum Error { #[snafu(display("Unsupported sql in coprocessor: {}", sql))] UnsupportedSql { sql: String, + #[snafu(implicit)] location: SnafuLocation, }, #[snafu(display("Failed to retrieve record batches"))] RecordBatch { + #[snafu(implicit)] location: SnafuLocation, source: common_recordbatch::error::Error, }, #[snafu(display("Failed to create record batch"))] NewRecordBatch { + #[snafu(implicit)] location: SnafuLocation, source: common_recordbatch::error::Error, }, diff --git a/src/servers/src/error.rs b/src/servers/src/error.rs index f9ef72c65c2c..375206d33707 100644 --- a/src/servers/src/error.rs +++ b/src/servers/src/error.rs @@ -65,6 +65,7 @@ pub enum Error { #[snafu(display("Failed to collect recordbatch"))] CollectRecordbatch { + #[snafu(implicit)] location: Location, source: common_recordbatch::error::Error, }, @@ -82,7 +83,11 @@ pub enum Error { }, #[snafu(display("{} server is already started", server))] - AlreadyStarted { server: String, location: Location }, + AlreadyStarted { + server: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to bind address {}", addr))] TcpBind { @@ -99,30 +104,35 @@ pub enum Error { #[snafu(display("Failed to execute query"))] ExecuteQuery { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Failed to execute plan"))] ExecutePlan { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Execute gRPC query error"))] ExecuteGrpcQuery { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Execute gRPC request error"))] ExecuteGrpcRequest { + #[snafu(implicit)] location: Location, source: BoxedError, }, #[snafu(display("Failed to check database validity"))] CheckDatabaseValidity { + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -133,6 +143,7 @@ pub enum Error { #[snafu(display("Failed to insert script with name: {}", name))] InsertScript { name: String, + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -140,6 +151,7 @@ pub enum Error { #[snafu(display("Failed to execute script by name: {}", name))] ExecuteScript { name: String, + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -148,13 +160,22 @@ pub enum Error { NotSupported { feat: String }, #[snafu(display("Invalid request parameter: {}", reason))] - InvalidParameter { reason: String, location: Location }, + InvalidParameter { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid query: {}", reason))] - InvalidQuery { reason: String, location: Location }, + InvalidQuery { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to parse InfluxDB line protocol"))] InfluxdbLineProtocol { + #[snafu(implicit)] location: Location, #[snafu(source)] error: influxdb_line_protocol::Error, @@ -162,27 +183,37 @@ pub enum Error { #[snafu(display("Failed to write row"))] RowWriter { + #[snafu(implicit)] location: Location, source: common_grpc::error::Error, }, #[snafu(display("Failed to write prometheus series"))] PromSeriesWrite { + #[snafu(implicit)] location: Location, source: common_grpc::error::Error, }, #[snafu(display("Failed to write OTLP metrics"))] OtlpMetricsWrite { + #[snafu(implicit)] location: Location, source: common_grpc::error::Error, }, #[snafu(display("Failed to convert time precision, name: {}", name))] - TimePrecision { name: String, location: Location }, + TimePrecision { + name: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Connection reset by peer"))] - ConnResetByPeer { location: Location }, + ConnResetByPeer { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Hyper error"))] Hyper { @@ -194,11 +225,13 @@ pub enum Error { InvalidOpentsdbJsonRequest { #[snafu(source)] error: serde_json::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to decode prometheus remote request"))] DecodePromRemoteRequest { + #[snafu(implicit)] location: Location, #[snafu(source)] error: prost::DecodeError, @@ -206,6 +239,7 @@ pub enum Error { #[snafu(display("Failed to decode OTLP request"))] DecodeOtlpRequest { + #[snafu(implicit)] location: Location, #[snafu(source)] error: prost::DecodeError, @@ -213,6 +247,7 @@ pub enum Error { #[snafu(display("Failed to decompress snappy prometheus remote request"))] DecompressSnappyPromRemoteRequest { + #[snafu(implicit)] location: Location, #[snafu(source)] error: snap::Error, @@ -220,6 +255,7 @@ pub enum Error { #[snafu(display("Failed to decompress zstd prometheus remote request"))] DecompressZstdPromRemoteRequest { + #[snafu(implicit)] location: Location, #[snafu(source)] error: std::io::Error, @@ -227,31 +263,46 @@ pub enum Error { #[snafu(display("Failed to send prometheus remote request"))] SendPromRemoteRequest { + #[snafu(implicit)] location: Location, #[snafu(source)] error: reqwest::Error, }, #[snafu(display("Invalid export metrics config, msg: {}", msg))] - InvalidExportMetricsConfig { msg: String, location: Location }, + InvalidExportMetricsConfig { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to compress prometheus remote request"))] CompressPromRemoteRequest { + #[snafu(implicit)] location: Location, #[snafu(source)] error: snap::Error, }, #[snafu(display("Invalid prometheus remote request, msg: {}", msg))] - InvalidPromRemoteRequest { msg: String, location: Location }, + InvalidPromRemoteRequest { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid prometheus remote read query result, msg: {}", msg))] - InvalidPromRemoteReadQueryResult { msg: String, location: Location }, + InvalidPromRemoteReadQueryResult { + msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid Flight ticket"))] InvalidFlightTicket { #[snafu(source)] error: api::DecodeError, + #[snafu(implicit)] location: Location, }, @@ -260,6 +311,7 @@ pub enum Error { #[snafu(display("Failed to get user info"))] Auth { + #[snafu(implicit)] location: Location, source: auth::error::Error, }, @@ -277,6 +329,7 @@ pub enum Error { InvalidAuthHeaderInvisibleASCII { #[snafu(source)] error: hyper::header::ToStrError, + #[snafu(implicit)] location: Location, }, @@ -284,16 +337,21 @@ pub enum Error { InvalidAuthHeaderInvalidUtf8Value { #[snafu(source)] error: FromUtf8Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid http authorization header"))] - InvalidAuthHeader { location: Location }, + InvalidAuthHeader { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid base64 value"))] InvalidBase64Value { #[snafu(source)] error: DecodeError, + #[snafu(implicit)] location: Location, }, @@ -301,12 +359,14 @@ pub enum Error { InvalidUtf8Value { #[snafu(source)] error: FromUtf8Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Error accessing catalog"))] CatalogError { source: catalog::error::Error, + #[snafu(implicit)] location: Location, }, @@ -314,6 +374,7 @@ pub enum Error { DatabaseNotFound { catalog: String, schema: String, + #[snafu(implicit)] location: Location, }, @@ -322,26 +383,37 @@ pub enum Error { catalog: String, schema: String, table: String, + #[snafu(implicit)] location: Location, }, #[cfg(feature = "mem-prof")] #[snafu(display("Failed to dump profile data"))] DumpProfileData { + #[snafu(implicit)] location: Location, source: common_mem_prof::error::Error, }, #[snafu(display("Invalid prepare statement: {}", err_msg))] - InvalidPrepareStatement { err_msg: String, location: Location }, + InvalidPrepareStatement { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid flush argument: {}", err_msg))] - InvalidFlushArgument { err_msg: String, location: Location }, + InvalidFlushArgument { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to build gRPC reflection service"))] GrpcReflectionService { #[snafu(source)] error: tonic_reflection::server::Error, + #[snafu(implicit)] location: Location, }, @@ -349,12 +421,14 @@ pub enum Error { BuildHttpResponse { #[snafu(source)] error: http::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to parse PromQL: {query:?}"))] ParsePromQL { query: Box, + #[snafu(implicit)] location: Location, source: query::error::Error, }, @@ -362,17 +436,23 @@ pub enum Error { #[snafu(display("Failed to get param types"))] GetPreparedStmtParams { source: query::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("{}", reason))] - UnexpectedResult { reason: String, location: Location }, + UnexpectedResult { + reason: String, + #[snafu(implicit)] + location: Location, + }, // this error is used for custom error mapping // please do not delete it #[snafu(display("Other error"))] Other { source: BoxedError, + #[snafu(implicit)] location: Location, }, @@ -380,6 +460,7 @@ pub enum Error { JoinTask { #[snafu(source)] error: tokio::task::JoinError, + #[snafu(implicit)] location: Location, }, @@ -394,6 +475,7 @@ pub enum Error { UpdateJemallocMetrics { #[snafu(source)] error: tikv_jemalloc_ctl::Error, + #[snafu(implicit)] location: Location, }, @@ -401,18 +483,21 @@ pub enum Error { DataFrame { #[snafu(source)] error: datafusion::error::DataFusionError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to replace params with values in prepared statement"))] ReplacePreparedStmtParams { source: query::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to convert scalar value"))] ConvertScalarValue { source: datatypes::error::Error, + #[snafu(implicit)] location: Location, }, @@ -420,6 +505,7 @@ pub enum Error { PreparedStmtTypeMismatch { expected: ConcreteDataType, actual: opensrv_mysql::ColumnType, + #[snafu(implicit)] location: Location, }, @@ -435,6 +521,7 @@ pub enum Error { datatype: String, expected: i32, actual: i32, + #[snafu(implicit)] location: Location, }, @@ -442,6 +529,7 @@ pub enum Error { ToJson { #[snafu(source)] error: serde_json::error::Error, + #[snafu(implicit)] location: Location, }, @@ -449,19 +537,30 @@ pub enum Error { UrlDecode { #[snafu(source)] error: FromUtf8Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to convert Mysql value, error: {}", err_msg))] - MysqlValueConversion { err_msg: String, location: Location }, + MysqlValueConversion { + err_msg: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Missing query context"))] - MissingQueryContext { location: Location }, + MissingQueryContext { + #[snafu(implicit)] + location: Location, + }, #[snafu(display( "Invalid parameter, physical_table is not expected when metric engine is disabled" ))] - UnexpectedPhysicalTable { location: Location }, + UnexpectedPhysicalTable { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to initialize a watcher for file {}", path))] FileWatch { @@ -471,7 +570,11 @@ pub enum Error { }, #[snafu(display("Timestamp overflow: {}", error))] - TimestampOverflow { error: String, location: Location }, + TimestampOverflow { + error: String, + #[snafu(implicit)] + location: Location, + }, } pub type Result = std::result::Result; diff --git a/src/servers/src/http/pprof/nix.rs b/src/servers/src/http/pprof/nix.rs index 4b9c0918886d..12a518e1de02 100644 --- a/src/servers/src/http/pprof/nix.rs +++ b/src/servers/src/http/pprof/nix.rs @@ -28,6 +28,7 @@ pub enum Error { CreateGuard { #[snafu(source)] error: pprof::Error, + #[snafu(implicit)] location: Location, }, @@ -35,6 +36,7 @@ pub enum Error { CreateReport { #[snafu(source)] error: pprof::Error, + #[snafu(implicit)] location: Location, }, @@ -42,6 +44,7 @@ pub enum Error { CreateFlamegraph { #[snafu(source)] error: pprof::Error, + #[snafu(implicit)] location: Location, }, @@ -49,6 +52,7 @@ pub enum Error { ReportPprof { #[snafu(source)] error: pprof::Error, + #[snafu(implicit)] location: Location, }, } diff --git a/src/session/src/session_config.rs b/src/session/src/session_config.rs index 2f6bdbbf406c..8b93ce2a2cc9 100644 --- a/src/session/src/session_config.rs +++ b/src/session/src/session_config.rs @@ -27,6 +27,7 @@ pub enum Error { name: String, value: String, hint: String, + #[snafu(implicit)] location: Location, }, } diff --git a/src/sql/src/error.rs b/src/sql/src/error.rs index 6f1516d78f69..71669f6ecd73 100644 --- a/src/sql/src/error.rs +++ b/src/sql/src/error.rs @@ -65,6 +65,7 @@ pub enum Error { Syntax { #[snafu(source)] error: ParserError, + #[snafu(implicit)] location: Location, }, @@ -73,6 +74,7 @@ pub enum Error { TQLSyntax { #[snafu(source)] error: TQLError, + #[snafu(implicit)] location: Location, }, @@ -127,6 +129,7 @@ pub enum Error { #[snafu(display("Invalid default constraint, column: {}", column))] InvalidDefault { column: String, + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, @@ -135,28 +138,36 @@ pub enum Error { InvalidCast { sql_value: sqlparser::ast::Value, datatype: ConcreteDataType, + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, #[snafu(display("Unrecognized table option key: {}", key))] - InvalidTableOption { key: String, location: Location }, + InvalidTableOption { + key: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Unrecognized table option key: {}, value: {}", key, value))] InvalidTableOptionValue { key: Ident, value: Expr, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to serialize column default constraint"))] SerializeColumnDefaultConstraint { + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, #[snafu(display("Failed to convert data type to gRPC data type defined in proto"))] ConvertToGrpcDataType { + #[snafu(implicit)] location: Location, source: api::error::Error, }, @@ -177,6 +188,7 @@ pub enum Error { #[snafu(display("Unable to convert statement {} to DataFusion statement", statement))] ConvertToDfStatement { statement: String, + #[snafu(implicit)] location: Location, }, @@ -184,11 +196,16 @@ pub enum Error { ConvertSqlValue { value: SqlValue, datatype: ConcreteDataType, + #[snafu(implicit)] location: Location, }, #[snafu(display("Unable to convert value {} to sql value", value))] - ConvertValue { value: Value, location: Location }, + ConvertValue { + value: Value, + #[snafu(implicit)] + location: Location, + }, } impl ErrorExt for Error { diff --git a/src/sql/src/parsers/error.rs b/src/sql/src/parsers/error.rs index bdb469ac2bae..988aa27f5493 100644 --- a/src/sql/src/parsers/error.rs +++ b/src/sql/src/parsers/error.rs @@ -26,6 +26,7 @@ pub enum TQLError { Parser { #[snafu(source)] error: ParserError, + #[snafu(implicit)] location: Location, }, @@ -33,6 +34,7 @@ pub enum TQLError { ConvertToLogicalExpression { #[snafu(source)] error: DataFusionError, + #[snafu(implicit)] location: Location, }, @@ -40,6 +42,7 @@ pub enum TQLError { Simplification { #[snafu(source)] error: DataFusionError, + #[snafu(implicit)] location: Location, }, diff --git a/src/store-api/src/metadata.rs b/src/store-api/src/metadata.rs index 2df29580984b..36f41696f6c9 100644 --- a/src/store-api/src/metadata.rs +++ b/src/store-api/src/metadata.rs @@ -694,14 +694,20 @@ pub enum MetadataError { #[snafu(display("Invalid schema"))] InvalidSchema { source: datatypes::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid metadata, {}", reason))] - InvalidMeta { reason: String, location: Location }, + InvalidMeta { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to ser/de json object"))] SerdeJson { + #[snafu(implicit)] location: Location, #[snafu(source)] error: serde_json::Error, @@ -709,17 +715,23 @@ pub enum MetadataError { #[snafu(display("Failed to convert struct from datatypes"))] ConvertDatatypes { + #[snafu(implicit)] location: Location, source: datatypes::error::Error, }, #[snafu(display("Invalid raw region request, err: {}", err))] - InvalidRawRegionRequest { err: String, location: Location }, + InvalidRawRegionRequest { + err: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Invalid region request, region_id: {}, err: {}", region_id, err))] InvalidRegionRequest { region_id: RegionId, err: String, + #[snafu(implicit)] location: Location, }, @@ -727,17 +739,22 @@ pub enum MetadataError { SchemaProject { origin_schema: SchemaRef, projection: Vec, + #[snafu(implicit)] location: Location, source: datatypes::Error, }, #[snafu(display("Time index column not found"))] - TimeIndexNotFound { location: Location }, + TimeIndexNotFound { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Change column {} not exists in region: {}", column_name, region_id))] ChangeColumnNotFound { column_name: String, region_id: RegionId, + #[snafu(implicit)] location: Location, }, } diff --git a/src/table/src/error.rs b/src/table/src/error.rs index b67dbac5e2f5..ee91e8304634 100644 --- a/src/table/src/error.rs +++ b/src/table/src/error.rs @@ -34,12 +34,14 @@ pub enum Error { Datafusion { #[snafu(source)] error: DataFusionError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to convert Arrow schema"))] SchemaConversion { source: datatypes::error::Error, + #[snafu(implicit)] location: Location, }, @@ -47,11 +49,13 @@ pub enum Error { TableProjection { #[snafu(source)] error: ArrowError, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to create record batch for Tables"))] TablesRecordBatch { + #[snafu(implicit)] location: Location, source: BoxedError, }, @@ -60,11 +64,13 @@ pub enum Error { ColumnExists { column_name: String, table_name: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to build schema, msg: {}", msg))] SchemaBuild { + #[snafu(implicit)] location: Location, source: datatypes::error::Error, msg: String, @@ -74,11 +80,16 @@ pub enum Error { ColumnNotExists { column_name: String, table_name: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Duplicated call to plan execute method. table: {}", table))] - DuplicatedExecuteCall { location: Location, table: String }, + DuplicatedExecuteCall { + #[snafu(implicit)] + location: Location, + table: String, + }, #[snafu(display( "Not allowed to remove index column {} from table {}", @@ -88,6 +99,7 @@ pub enum Error { RemoveColumnInIndex { column_name: String, table_name: String, + #[snafu(implicit)] location: Location, }, @@ -101,11 +113,16 @@ pub enum Error { error: store_api::storage::ColumnDescriptorBuilderError, table_name: String, column_name: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Regions schemas mismatch in table: {}", table))] - RegionSchemaMismatch { table: String, location: Location }, + RegionSchemaMismatch { + table: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to operate table"))] TableOperation { source: BoxedError }, @@ -117,12 +134,14 @@ pub enum Error { ParseTableOption { key: String, value: String, + #[snafu(implicit)] location: Location, }, #[snafu(display("Invalid alter table({}) request: {}", table, err))] InvalidAlterRequest { table: String, + #[snafu(implicit)] location: Location, err: String, }, @@ -130,12 +149,14 @@ pub enum Error { #[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, + #[snafu(implicit)] location: Location, }, } diff --git a/tests-fuzz/src/error.rs b/tests-fuzz/src/error.rs index 72033b257521..10259099a30f 100644 --- a/tests-fuzz/src/error.rs +++ b/tests-fuzz/src/error.rs @@ -28,6 +28,7 @@ pub enum Error { #[snafu(display("Failed to create a file: {}", path))] CreateFile { path: String, + #[snafu(implicit)] location: Location, #[snafu(source)] error: std::io::Error, @@ -36,6 +37,7 @@ pub enum Error { #[snafu(display("Failed to write a file: {}", path))] WriteFile { path: String, + #[snafu(implicit)] location: Location, #[snafu(source)] error: std::io::Error, @@ -44,6 +46,7 @@ pub enum Error { #[snafu(display("Unexpected, violated: {violated}"))] Unexpected { violated: String, + #[snafu(implicit)] location: Location, }, @@ -51,6 +54,7 @@ pub enum Error { BuildCreateTableExpr { #[snafu(source)] error: CreateTableExprBuilderError, + #[snafu(implicit)] location: Location, }, @@ -58,28 +62,41 @@ pub enum Error { BuildCreateDatabaseExpr { #[snafu(source)] error: CreateDatabaseExprBuilderError, + #[snafu(implicit)] location: Location, }, #[snafu(display("No droppable columns"))] - DroppableColumns { location: Location }, + DroppableColumns { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to execute query: {}", sql))] ExecuteQuery { sql: String, #[snafu(source)] error: sqlx::error::Error, + #[snafu(implicit)] location: Location, }, #[snafu(display("Failed to assert: {}", reason))] - Assert { reason: String, location: Location }, + Assert { + reason: String, + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Child process exited unexpected"))] - UnexpectedExited { location: Location }, + UnexpectedExited { + #[snafu(implicit)] + location: Location, + }, #[snafu(display("Failed to spawn a child process"))] SpawnChild { + #[snafu(implicit)] location: Location, #[snafu(source)] error: std::io::Error, @@ -88,6 +105,7 @@ pub enum Error { #[cfg(feature = "unstable")] #[snafu(display("Failed to kill a process, pid: {}", pid))] KillProcess { + #[snafu(implicit)] location: Location, #[snafu(source)] error: nix::Error,