mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-10-29 07:06:20 +00:00
feat: stack trace style debug print for error (#2489)
* impl macro stack_trace_debug Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * manually mark external error Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * ignore warnings Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * fix clippy warnings Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * use debug print Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * simplify the error and warn macro Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * fix ut Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * add docs Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * replace snafu backtrace with location Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
Generated
+35
@@ -208,6 +208,7 @@ version = "0.4.0-nightly"
|
||||
dependencies = [
|
||||
"common-base",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-time",
|
||||
"datatypes",
|
||||
"greptime-proto",
|
||||
@@ -690,6 +691,7 @@ dependencies = [
|
||||
"api",
|
||||
"async-trait",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-test-util",
|
||||
"digest",
|
||||
"hex",
|
||||
@@ -1250,6 +1252,7 @@ dependencies = [
|
||||
"common-catalog",
|
||||
"common-error",
|
||||
"common-grpc",
|
||||
"common-macro",
|
||||
"common-meta",
|
||||
"common-query",
|
||||
"common-recordbatch",
|
||||
@@ -1532,6 +1535,7 @@ dependencies = [
|
||||
"common-error",
|
||||
"common-grpc",
|
||||
"common-grpc-expr",
|
||||
"common-macro",
|
||||
"common-meta",
|
||||
"common-query",
|
||||
"common-recordbatch",
|
||||
@@ -1600,6 +1604,7 @@ dependencies = [
|
||||
"common-catalog",
|
||||
"common-config",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-meta",
|
||||
"common-procedure",
|
||||
"common-query",
|
||||
@@ -1672,6 +1677,7 @@ dependencies = [
|
||||
"bitvec",
|
||||
"bytes",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"paste",
|
||||
"serde",
|
||||
"snafu",
|
||||
@@ -1684,6 +1690,7 @@ version = "0.4.0-nightly"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"snafu",
|
||||
@@ -1709,6 +1716,7 @@ dependencies = [
|
||||
"async-trait",
|
||||
"bytes",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-runtime",
|
||||
"common-test-util",
|
||||
"datafusion",
|
||||
@@ -1787,6 +1795,7 @@ dependencies = [
|
||||
"backtrace",
|
||||
"common-base",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-recordbatch",
|
||||
"common-runtime",
|
||||
"common-telemetry",
|
||||
@@ -1815,6 +1824,7 @@ dependencies = [
|
||||
"common-base",
|
||||
"common-catalog",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-query",
|
||||
"common-telemetry",
|
||||
"common-time",
|
||||
@@ -1838,6 +1848,7 @@ dependencies = [
|
||||
"snafu",
|
||||
"static_assertions",
|
||||
"syn 1.0.109",
|
||||
"syn 2.0.29",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1845,6 +1856,7 @@ name = "common-mem-prof"
|
||||
version = "0.4.0-nightly"
|
||||
dependencies = [
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"snafu",
|
||||
"tempfile",
|
||||
"tikv-jemalloc-ctl",
|
||||
@@ -1864,6 +1876,7 @@ dependencies = [
|
||||
"common-catalog",
|
||||
"common-error",
|
||||
"common-grpc-expr",
|
||||
"common-macro",
|
||||
"common-procedure",
|
||||
"common-recordbatch",
|
||||
"common-runtime",
|
||||
@@ -1895,6 +1908,7 @@ dependencies = [
|
||||
"async-trait",
|
||||
"backon",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-runtime",
|
||||
"common-telemetry",
|
||||
"common-test-util",
|
||||
@@ -1926,6 +1940,7 @@ dependencies = [
|
||||
"async-trait",
|
||||
"common-base",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-recordbatch",
|
||||
"common-time",
|
||||
"datafusion",
|
||||
@@ -1945,6 +1960,7 @@ name = "common-recordbatch"
|
||||
version = "0.4.0-nightly"
|
||||
dependencies = [
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"datafusion",
|
||||
"datafusion-common",
|
||||
"datatypes",
|
||||
@@ -1962,6 +1978,7 @@ version = "0.4.0-nightly"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-telemetry",
|
||||
"metrics",
|
||||
"once_cell",
|
||||
@@ -2016,6 +2033,7 @@ dependencies = [
|
||||
"chrono",
|
||||
"chrono-tz 0.8.3",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"rand",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -2684,6 +2702,7 @@ dependencies = [
|
||||
"common-greptimedb-telemetry",
|
||||
"common-grpc",
|
||||
"common-grpc-expr",
|
||||
"common-macro",
|
||||
"common-meta",
|
||||
"common-procedure",
|
||||
"common-query",
|
||||
@@ -2741,6 +2760,7 @@ dependencies = [
|
||||
"arrow-schema",
|
||||
"common-base",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-telemetry",
|
||||
"common-time",
|
||||
"datafusion-common",
|
||||
@@ -3203,6 +3223,7 @@ dependencies = [
|
||||
"common-catalog",
|
||||
"common-datasource",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-procedure",
|
||||
"common-procedure-test",
|
||||
"common-query",
|
||||
@@ -3325,6 +3346,7 @@ dependencies = [
|
||||
"common-function",
|
||||
"common-grpc",
|
||||
"common-grpc-expr",
|
||||
"common-macro",
|
||||
"common-meta",
|
||||
"common-procedure",
|
||||
"common-query",
|
||||
@@ -5030,6 +5052,7 @@ dependencies = [
|
||||
"common-base",
|
||||
"common-config",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-meta",
|
||||
"common-runtime",
|
||||
"common-telemetry",
|
||||
@@ -5305,6 +5328,7 @@ dependencies = [
|
||||
"chrono",
|
||||
"common-error",
|
||||
"common-grpc",
|
||||
"common-macro",
|
||||
"common-meta",
|
||||
"common-telemetry",
|
||||
"datatypes",
|
||||
@@ -5341,6 +5365,7 @@ dependencies = [
|
||||
"common-greptimedb-telemetry",
|
||||
"common-grpc",
|
||||
"common-grpc-expr",
|
||||
"common-macro",
|
||||
"common-meta",
|
||||
"common-procedure",
|
||||
"common-procedure-test",
|
||||
@@ -5532,6 +5557,7 @@ dependencies = [
|
||||
"common-catalog",
|
||||
"common-datasource",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-procedure",
|
||||
"common-procedure-test",
|
||||
"common-query",
|
||||
@@ -6241,6 +6267,7 @@ dependencies = [
|
||||
"common-datasource",
|
||||
"common-error",
|
||||
"common-grpc-expr",
|
||||
"common-macro",
|
||||
"common-meta",
|
||||
"common-query",
|
||||
"common-recordbatch",
|
||||
@@ -6503,6 +6530,7 @@ dependencies = [
|
||||
"async-trait",
|
||||
"common-catalog",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-meta",
|
||||
"common-query",
|
||||
"common-telemetry",
|
||||
@@ -8626,6 +8654,7 @@ dependencies = [
|
||||
"common-catalog",
|
||||
"common-error",
|
||||
"common-function",
|
||||
"common-macro",
|
||||
"common-query",
|
||||
"common-recordbatch",
|
||||
"common-runtime",
|
||||
@@ -8916,6 +8945,7 @@ dependencies = [
|
||||
"common-error",
|
||||
"common-grpc",
|
||||
"common-grpc-expr",
|
||||
"common-macro",
|
||||
"common-mem-prof",
|
||||
"common-meta",
|
||||
"common-query",
|
||||
@@ -9272,6 +9302,7 @@ dependencies = [
|
||||
"common-catalog",
|
||||
"common-datasource",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-query",
|
||||
"common-time",
|
||||
"datafusion-sql",
|
||||
@@ -9536,6 +9567,7 @@ dependencies = [
|
||||
"common-config",
|
||||
"common-datasource",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-query",
|
||||
"common-recordbatch",
|
||||
"common-runtime",
|
||||
@@ -9583,6 +9615,7 @@ dependencies = [
|
||||
"bytes",
|
||||
"common-base",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-query",
|
||||
"common-recordbatch",
|
||||
"common-time",
|
||||
@@ -9718,6 +9751,7 @@ dependencies = [
|
||||
"catalog",
|
||||
"common-catalog",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-telemetry",
|
||||
"datafusion",
|
||||
"datafusion-common",
|
||||
@@ -9876,6 +9910,7 @@ dependencies = [
|
||||
"common-catalog",
|
||||
"common-datasource",
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-procedure",
|
||||
"common-query",
|
||||
"common-recordbatch",
|
||||
|
||||
@@ -7,6 +7,7 @@ license.workspace = true
|
||||
[dependencies]
|
||||
common-base = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-time = { workspace = true }
|
||||
datatypes = { workspace = true }
|
||||
greptime-proto.workspace = true
|
||||
|
||||
@@ -16,14 +16,16 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use datatypes::prelude::ConcreteDataType;
|
||||
use snafu::prelude::*;
|
||||
use snafu::Location;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Unknown proto column datatype: {}", datatype))]
|
||||
UnknownColumnDataType { datatype: i32, location: Location },
|
||||
|
||||
@@ -14,6 +14,7 @@ testing = []
|
||||
api.workspace = true
|
||||
async-trait.workspace = true
|
||||
common-error.workspace = true
|
||||
common-macro.workspace = true
|
||||
digest = "0.10"
|
||||
hex = { version = "0.4" }
|
||||
secrecy = { version = "0.8", features = ["serde", "alloc"] }
|
||||
|
||||
@@ -14,10 +14,12 @@
|
||||
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Invalid config value: {}, {}", value, msg))]
|
||||
InvalidConfig { value: String, msg: String },
|
||||
@@ -30,7 +32,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("IO error"))]
|
||||
Io {
|
||||
source: std::io::Error,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ async-trait = "0.1"
|
||||
common-catalog = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-grpc = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-meta = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
common-recordbatch = { workspace = true }
|
||||
|
||||
@@ -17,14 +17,16 @@ use std::fmt::Debug;
|
||||
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use datafusion::error::DataFusionError;
|
||||
use datatypes::prelude::ConcreteDataType;
|
||||
use snafu::{Location, Snafu};
|
||||
use table::metadata::TableId;
|
||||
use tokio::task::JoinError;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to list catalogs"))]
|
||||
ListCatalogs {
|
||||
@@ -92,7 +94,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to deserialize value"))]
|
||||
ValueDeserialize {
|
||||
source: serde_json::error::Error,
|
||||
#[snafu(source)]
|
||||
error: serde_json::error::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -142,7 +145,10 @@ pub enum Error {
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to open table in parallel"))]
|
||||
ParallelOpenTable { source: JoinError },
|
||||
ParallelOpenTable {
|
||||
#[snafu(source)]
|
||||
error: JoinError,
|
||||
},
|
||||
|
||||
#[snafu(display("Table not found while opening table, table info: {}", table_info))]
|
||||
TableNotFound {
|
||||
@@ -213,7 +219,8 @@ pub enum Error {
|
||||
#[snafu(display("msg: {}", msg))]
|
||||
Datafusion {
|
||||
msg: String,
|
||||
source: DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ common-base = { workspace = true }
|
||||
common-catalog = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-grpc = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-meta = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
common-recordbatch = { workspace = true }
|
||||
|
||||
@@ -42,14 +42,14 @@ async fn run() {
|
||||
.insert(vec![to_insert_request(weather_records_1())])
|
||||
.await
|
||||
{
|
||||
error!("Error: {e}");
|
||||
error!("Error: {e:?}");
|
||||
}
|
||||
|
||||
if let Err(e) = stream_inserter
|
||||
.insert(vec![to_insert_request(weather_records_2())])
|
||||
.await
|
||||
{
|
||||
error!("Error: {e}");
|
||||
error!("Error: {e:?}");
|
||||
}
|
||||
|
||||
let result = stream_inserter.finish().await;
|
||||
@@ -59,7 +59,7 @@ async fn run() {
|
||||
info!("Rows written: {rows}");
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Error: {e}");
|
||||
error!("Error: {e:?}");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ impl Database {
|
||||
source: BoxedError::new(ServerSnafu { code, msg }.build()),
|
||||
};
|
||||
logging::error!(
|
||||
"Failed to do Flight get, addr: {}, code: {}, source: {}",
|
||||
"Failed to do Flight get, addr: {}, code: {}, source: {:?}",
|
||||
client.addr(),
|
||||
tonic_code,
|
||||
error
|
||||
|
||||
@@ -17,11 +17,13 @@ use std::any::Any;
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_error::{GREPTIME_ERROR_CODE, GREPTIME_ERROR_MSG};
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::{Location, Snafu};
|
||||
use tonic::{Code, Status};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Illegal Flight messages, reason: {}", reason))]
|
||||
IllegalFlightMessages { reason: String, location: Location },
|
||||
|
||||
@@ -26,6 +26,7 @@ common-base = { workspace = true }
|
||||
common-catalog = { workspace = true }
|
||||
common-config = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-meta = { workspace = true }
|
||||
common-procedure = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
|
||||
+11
-5
@@ -16,12 +16,14 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use config::ConfigError;
|
||||
use rustyline::error::ReadlineError;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to create default catalog and schema"))]
|
||||
InitMetadata {
|
||||
@@ -101,13 +103,15 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Cannot create REPL"))]
|
||||
ReplCreation {
|
||||
source: ReadlineError,
|
||||
#[snafu(source)]
|
||||
error: ReadlineError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Error reading command"))]
|
||||
Readline {
|
||||
source: ReadlineError,
|
||||
#[snafu(source)]
|
||||
error: ReadlineError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -157,7 +161,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to load layered config"))]
|
||||
LoadLayeredConfig {
|
||||
source: ConfigError,
|
||||
#[snafu(source)]
|
||||
error: ConfigError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -170,7 +175,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to connect to Etcd at {etcd_addr}"))]
|
||||
ConnectEtcd {
|
||||
etcd_addr: String,
|
||||
source: etcd_client::Error,
|
||||
#[snafu(source)]
|
||||
error: etcd_client::Error,
|
||||
location: Location,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ anymap = "1.0.0-beta.2"
|
||||
bitvec = "1.0"
|
||||
bytes = { version = "1.1", features = ["serde"] }
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
paste = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
snafu.workspace = true
|
||||
|
||||
@@ -17,11 +17,13 @@ use std::io::{Read, Write};
|
||||
|
||||
use bytes::{Buf, BufMut, BytesMut};
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_macro::stack_trace_debug;
|
||||
use paste::paste;
|
||||
use snafu::{ensure, Location, ResultExt, Snafu};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display(
|
||||
"Destination buffer overflow, src_len: {}, dst_len: {}",
|
||||
@@ -39,7 +41,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("IO operation reach EOF"))]
|
||||
Eof {
|
||||
source: std::io::Error,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
location: Location,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
serde.workspace = true
|
||||
serde_json = "1.0"
|
||||
snafu = { version = "0.7", features = ["backtraces"] }
|
||||
|
||||
@@ -16,10 +16,12 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Invalid full table name: {}", table_name))]
|
||||
InvalidFullTableName {
|
||||
|
||||
@@ -18,6 +18,7 @@ async-compression = { version = "0.3", features = [
|
||||
async-trait.workspace = true
|
||||
bytes = "1.1"
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-runtime = { workspace = true }
|
||||
datafusion.workspace = true
|
||||
derive_builder.workspace = true
|
||||
|
||||
@@ -17,12 +17,14 @@ use std::any::Any;
|
||||
use arrow_schema::ArrowError;
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use datafusion::parquet::errors::ParquetError;
|
||||
use snafu::{Location, Snafu};
|
||||
use url::ParseError;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Unsupported compression type: {}", compression_type))]
|
||||
UnsupportedCompressionType {
|
||||
@@ -46,83 +48,96 @@ pub enum Error {
|
||||
#[snafu(display("Invalid url: {}", url))]
|
||||
InvalidUrl {
|
||||
url: String,
|
||||
source: ParseError,
|
||||
#[snafu(source)]
|
||||
error: ParseError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to build backend"))]
|
||||
BuildBackend {
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to build orc reader"))]
|
||||
OrcReader {
|
||||
location: Location,
|
||||
source: orc_rust::error::Error,
|
||||
#[snafu(source)]
|
||||
error: orc_rust::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to read object from path: {}", path))]
|
||||
ReadObject {
|
||||
path: String,
|
||||
location: Location,
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to write object to path: {}", path))]
|
||||
WriteObject {
|
||||
path: String,
|
||||
location: Location,
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to write"))]
|
||||
AsyncWrite {
|
||||
source: std::io::Error,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to write record batch"))]
|
||||
WriteRecordBatch {
|
||||
location: Location,
|
||||
source: ArrowError,
|
||||
#[snafu(source)]
|
||||
error: ArrowError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to encode record batch"))]
|
||||
EncodeRecordBatch {
|
||||
location: Location,
|
||||
source: ParquetError,
|
||||
#[snafu(source)]
|
||||
error: ParquetError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to read record batch"))]
|
||||
ReadRecordBatch {
|
||||
location: Location,
|
||||
source: datafusion::error::DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: datafusion::error::DataFusionError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to read parquet"))]
|
||||
ReadParquetSnafu {
|
||||
location: Location,
|
||||
source: datafusion::parquet::errors::ParquetError,
|
||||
#[snafu(source)]
|
||||
error: datafusion::parquet::errors::ParquetError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to convert parquet to schema"))]
|
||||
ParquetToSchema {
|
||||
location: Location,
|
||||
source: datafusion::parquet::errors::ParquetError,
|
||||
#[snafu(source)]
|
||||
error: datafusion::parquet::errors::ParquetError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to infer schema from file"))]
|
||||
InferSchema {
|
||||
location: Location,
|
||||
source: arrow_schema::ArrowError,
|
||||
#[snafu(source)]
|
||||
error: arrow_schema::ArrowError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to list object in path: {}", path))]
|
||||
ListObjects {
|
||||
path: String,
|
||||
location: Location,
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Invalid connection: {}", msg))]
|
||||
@@ -131,7 +146,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to join handle"))]
|
||||
JoinHandle {
|
||||
location: Location,
|
||||
source: tokio::task::JoinError,
|
||||
#[snafu(source)]
|
||||
error: tokio::task::JoinError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse format {} with value: {}", key, value))]
|
||||
@@ -143,7 +159,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to merge schema"))]
|
||||
MergeSchema {
|
||||
source: arrow_schema::ArrowError,
|
||||
#[snafu(source)]
|
||||
error: arrow_schema::ArrowError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -13,11 +13,12 @@
|
||||
// limitations under the License.
|
||||
|
||||
use std::any::Any;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::status_code::StatusCode;
|
||||
|
||||
/// Extension to [`Error`](std::error::Error) in std.
|
||||
pub trait ErrorExt: std::error::Error {
|
||||
pub trait ErrorExt: std::error::Error + StackError {
|
||||
/// Map this error to [StatusCode].
|
||||
fn status_code(&self) -> StatusCode {
|
||||
StatusCode::Unknown
|
||||
@@ -35,6 +36,32 @@ pub trait ErrorExt: std::error::Error {
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
}
|
||||
|
||||
pub trait StackError {
|
||||
fn debug_fmt(&self, layer: usize, buf: &mut Vec<String>);
|
||||
|
||||
fn next(&self) -> Option<&dyn StackError>;
|
||||
}
|
||||
|
||||
impl<T: ?Sized + StackError> StackError for Arc<T> {
|
||||
fn debug_fmt(&self, layer: usize, buf: &mut Vec<String>) {
|
||||
self.as_ref().debug_fmt(layer, buf)
|
||||
}
|
||||
|
||||
fn next(&self) -> Option<&dyn StackError> {
|
||||
self.as_ref().next()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: ?Sized + StackError> StackError for Box<T> {
|
||||
fn debug_fmt(&self, layer: usize, buf: &mut Vec<String>) {
|
||||
self.as_ref().debug_fmt(layer, buf)
|
||||
}
|
||||
|
||||
fn next(&self) -> Option<&dyn StackError> {
|
||||
self.as_ref().next()
|
||||
}
|
||||
}
|
||||
|
||||
/// An opaque boxed error based on errors that implement [ErrorExt] trait.
|
||||
pub struct BoxedError {
|
||||
inner: Box<dyn crate::ext::ErrorExt + Send + Sync>,
|
||||
@@ -90,6 +117,16 @@ impl crate::snafu::ErrorCompat for BoxedError {
|
||||
}
|
||||
}
|
||||
|
||||
impl StackError for BoxedError {
|
||||
fn debug_fmt(&self, layer: usize, buf: &mut Vec<String>) {
|
||||
self.inner.debug_fmt(layer, buf)
|
||||
}
|
||||
|
||||
fn next(&self) -> Option<&dyn StackError> {
|
||||
self.inner.next()
|
||||
}
|
||||
}
|
||||
|
||||
/// Error type with plain error message
|
||||
#[derive(Debug)]
|
||||
pub struct PlainError {
|
||||
@@ -128,3 +165,13 @@ impl crate::ext::ErrorExt for PlainError {
|
||||
self as _
|
||||
}
|
||||
}
|
||||
|
||||
impl StackError for PlainError {
|
||||
fn debug_fmt(&self, layer: usize, buf: &mut Vec<String>) {
|
||||
buf.push(format!("{}: {}", layer, self.msg))
|
||||
}
|
||||
|
||||
fn next(&self) -> Option<&dyn StackError> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ mod tests {
|
||||
use snafu::{GenerateImplicitData, Location};
|
||||
|
||||
use super::*;
|
||||
use crate::ext::StackError;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[snafu(display("This is a leaf error"))]
|
||||
@@ -65,6 +66,14 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
impl StackError for Leaf {
|
||||
fn debug_fmt(&self, _: usize, _: &mut Vec<String>) {}
|
||||
|
||||
fn next(&self) -> Option<&dyn StackError> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[snafu(display("This is a leaf with location"))]
|
||||
struct LeafWithLocation {
|
||||
@@ -81,6 +90,14 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
impl StackError for LeafWithLocation {
|
||||
fn debug_fmt(&self, _: usize, _: &mut Vec<String>) {}
|
||||
|
||||
fn next(&self) -> Option<&dyn StackError> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[snafu(display("Internal error"))]
|
||||
struct Internal {
|
||||
@@ -99,6 +116,17 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
impl StackError for Internal {
|
||||
fn debug_fmt(&self, layer: usize, buf: &mut Vec<String>) {
|
||||
buf.push(format!("{}: Internal error, at {}", layer, self.location));
|
||||
self.source.debug_fmt(layer + 1, buf);
|
||||
}
|
||||
|
||||
fn next(&self) -> Option<&dyn StackError> {
|
||||
Some(&self.source)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_debug_format() {
|
||||
let err = Leaf;
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::fmt;
|
||||
|
||||
use snafu::Location;
|
||||
|
||||
use crate::ext::ErrorExt;
|
||||
use crate::ext::{ErrorExt, StackError};
|
||||
use crate::status_code::StatusCode;
|
||||
|
||||
/// A mock error mainly for test.
|
||||
@@ -69,3 +69,11 @@ impl ErrorExt for MockError {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl StackError for MockError {
|
||||
fn debug_fmt(&self, _: usize, _: &mut Vec<String>) {}
|
||||
|
||||
fn next(&self) -> Option<&dyn StackError> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ async-trait.workspace = true
|
||||
common-base = { workspace = true }
|
||||
common-catalog = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
common-telemetry = { workspace = true }
|
||||
common-time = { workspace = true }
|
||||
|
||||
@@ -16,10 +16,12 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Illegal delete request, reason: {reason}"))]
|
||||
IllegalDeleteRequest { reason: String, location: Location },
|
||||
|
||||
@@ -11,6 +11,7 @@ async-trait = "0.1"
|
||||
backtrace = "0.3"
|
||||
common-base = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-recordbatch = { workspace = true }
|
||||
common-runtime = { workspace = true }
|
||||
common-telemetry = { workspace = true }
|
||||
|
||||
@@ -17,19 +17,22 @@ use std::io;
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Invalid client tls config, {}", msg))]
|
||||
InvalidTlsConfig { msg: String },
|
||||
|
||||
#[snafu(display("Invalid config file path"))]
|
||||
InvalidConfigFilePath {
|
||||
source: io::Error,
|
||||
#[snafu(source)]
|
||||
error: io::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -48,7 +51,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to create gRPC channel"))]
|
||||
CreateChannel {
|
||||
source: tonic::transport::Error,
|
||||
#[snafu(source)]
|
||||
error: tonic::transport::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -63,7 +67,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to decode FlightData"))]
|
||||
DecodeFlightData {
|
||||
source: api::DecodeError,
|
||||
#[snafu(source)]
|
||||
error: api::DecodeError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -13,6 +13,15 @@ common-telemetry = { workspace = true }
|
||||
proc-macro2 = "1.0.66"
|
||||
quote = "1.0"
|
||||
syn = "1.0"
|
||||
syn2 = { version = "2.0", package = "syn", features = [
|
||||
"derive",
|
||||
"parsing",
|
||||
"printing",
|
||||
"clone-impls",
|
||||
"proc-macro",
|
||||
"extra-traits",
|
||||
"full",
|
||||
] }
|
||||
|
||||
[dev-dependencies]
|
||||
arc-swap = "1.0"
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
mod aggr_func;
|
||||
mod print_caller;
|
||||
mod range_fn;
|
||||
mod stack_trace_debug;
|
||||
|
||||
use aggr_func::{impl_aggr_func_type_store, impl_as_aggr_func_creator};
|
||||
use print_caller::process_print_caller;
|
||||
@@ -87,3 +88,23 @@ pub fn range_fn(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
pub fn print_caller(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
process_print_caller(args, input)
|
||||
}
|
||||
|
||||
/// Attribute macro to derive [std::fmt::Debug] for the annotated `Error` type.
|
||||
///
|
||||
/// The generated `Debug` implementation will print the error in a stack trace style. E.g.:
|
||||
/// ```plaintext
|
||||
/// 0: Foo error, at src/common/catalog/src/error.rs:80:10
|
||||
/// 1: Bar error, at src/common/function/src/error.rs:90:10
|
||||
/// 2: Root cause, invalid table name, at src/common/catalog/src/error.rs:100:10
|
||||
/// ```
|
||||
///
|
||||
/// Notes on using this macro:
|
||||
/// - `#[snafu(display)]` must present on each enum variants,
|
||||
/// and should not include `location` and `source`.
|
||||
/// - Only our internal error can be named `source`.
|
||||
/// All external error should be `error` with an `#[snafu(source)]` annotation.
|
||||
/// - `common_error` crate must be accessible.
|
||||
#[proc_macro_attribute]
|
||||
pub fn stack_trace_debug(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
stack_trace_debug::stack_trace_style_impl(args.into(), input.into()).into()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
// Copyright 2023 Greptime Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! implement `::common_error::ext::StackError`
|
||||
|
||||
use proc_macro2::{Span, TokenStream as TokenStream2};
|
||||
use quote::{quote, quote_spanned};
|
||||
use syn2::spanned::Spanned;
|
||||
use syn2::{parenthesized, Attribute, Ident, ItemEnum, Variant};
|
||||
|
||||
pub fn stack_trace_style_impl(args: TokenStream2, input: TokenStream2) -> TokenStream2 {
|
||||
let input_cloned: TokenStream2 = input.clone();
|
||||
|
||||
let error_enum_definition: ItemEnum = syn2::parse2(input_cloned).unwrap();
|
||||
let enum_name = error_enum_definition.ident;
|
||||
|
||||
let mut variants = vec![];
|
||||
|
||||
for error_variant in error_enum_definition.variants {
|
||||
let variant = ErrorVariant::from_enum_variant(error_variant);
|
||||
variants.push(variant);
|
||||
}
|
||||
|
||||
let debug_fmt_fn = build_debug_fmt_impl(enum_name.clone(), variants.clone());
|
||||
let next_fn = build_next_impl(enum_name.clone(), variants);
|
||||
let debug_impl = build_debug_impl(enum_name.clone());
|
||||
|
||||
quote! {
|
||||
#args
|
||||
#input
|
||||
|
||||
impl ::common_error::ext::StackError for #enum_name {
|
||||
#debug_fmt_fn
|
||||
#next_fn
|
||||
}
|
||||
|
||||
#debug_impl
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate `debug_fmt` fn.
|
||||
///
|
||||
/// The generated fn will be like:
|
||||
/// ```rust, ignore
|
||||
/// fn debug_fmt(&self, layer: usize, buf: &mut Vec<String>);
|
||||
/// ```
|
||||
fn build_debug_fmt_impl(enum_name: Ident, variants: Vec<ErrorVariant>) -> TokenStream2 {
|
||||
let match_arms = variants
|
||||
.iter()
|
||||
.map(|v| v.to_debug_match_arm())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
quote! {
|
||||
fn debug_fmt(&self, layer: usize, buf: &mut Vec<String>) {
|
||||
use #enum_name::*;
|
||||
match self {
|
||||
#(#match_arms)*
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate `next` fn.
|
||||
///
|
||||
/// The generated fn will be like:
|
||||
/// ```rust, ignore
|
||||
/// fn next(&self) -> Option<&dyn ::common_error::ext::StackError>;
|
||||
/// ```
|
||||
fn build_next_impl(enum_name: Ident, variants: Vec<ErrorVariant>) -> TokenStream2 {
|
||||
let match_arms = variants
|
||||
.iter()
|
||||
.map(|v| v.to_next_match_arm())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
quote! {
|
||||
fn next(&self) -> Option<&dyn ::common_error::ext::StackError> {
|
||||
use #enum_name::*;
|
||||
match self {
|
||||
#(#match_arms)*
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Implement [std::fmt::Debug] via `debug_fmt`
|
||||
fn build_debug_impl(enum_name: Ident) -> TokenStream2 {
|
||||
quote! {
|
||||
impl std::fmt::Debug for #enum_name {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
use ::common_error::ext::StackError;
|
||||
let mut buf = vec![];
|
||||
self.debug_fmt(0, &mut buf);
|
||||
write!(f, "{}", buf.join("\n"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct ErrorVariant {
|
||||
name: Ident,
|
||||
fields: Vec<Ident>,
|
||||
has_location: bool,
|
||||
has_source: bool,
|
||||
has_external_cause: bool,
|
||||
display: TokenStream2,
|
||||
span: Span,
|
||||
cfg_attr: Option<Attribute>,
|
||||
}
|
||||
|
||||
impl ErrorVariant {
|
||||
/// Construct self from [Variant]
|
||||
fn from_enum_variant(variant: Variant) -> Self {
|
||||
let span = variant.span();
|
||||
let mut has_location = false;
|
||||
let mut has_source = false;
|
||||
let mut has_external_cause = false;
|
||||
|
||||
for field in &variant.fields {
|
||||
if let Some(ident) = &field.ident {
|
||||
if ident == "location" {
|
||||
has_location = true;
|
||||
} else if ident == "source" {
|
||||
has_source = true;
|
||||
} else if ident == "error" {
|
||||
has_external_cause = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut display = None;
|
||||
let mut cfg_attr = None;
|
||||
for attr in variant.attrs {
|
||||
if attr.path().is_ident("snafu") {
|
||||
attr.parse_nested_meta(|meta| {
|
||||
if meta.path.is_ident("display") {
|
||||
let content;
|
||||
parenthesized!(content in meta.input);
|
||||
let display_ts: TokenStream2 = content.parse()?;
|
||||
display = Some(display_ts);
|
||||
Ok(())
|
||||
} else {
|
||||
Err(meta.error("unrecognized repr"))
|
||||
}
|
||||
})
|
||||
.expect("Each error should contains a display attribute");
|
||||
}
|
||||
|
||||
if attr.path().is_ident("cfg") {
|
||||
cfg_attr = Some(attr);
|
||||
}
|
||||
}
|
||||
|
||||
let field_ident = variant
|
||||
.fields
|
||||
.iter()
|
||||
.map(|f| f.ident.clone().unwrap_or_else(|| Ident::new("_", f.span())))
|
||||
.collect();
|
||||
|
||||
Self {
|
||||
name: variant.ident,
|
||||
fields: field_ident,
|
||||
has_location,
|
||||
has_source,
|
||||
has_external_cause,
|
||||
display: display.unwrap(),
|
||||
span,
|
||||
cfg_attr,
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert self into an match arm that will be used in [build_debug_impl].
|
||||
///
|
||||
/// The generated match arm will be like:
|
||||
/// ```rust, ignore
|
||||
/// ErrorKindWithSource { source, .. } => {
|
||||
/// debug_fmt(source, layer + 1, buf);
|
||||
/// },
|
||||
/// ErrorKindWithoutSource { .. } => {
|
||||
/// buf.push(format!("{layer}: {}, at {}", format!(#display), location)));
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// The generated code assumes fn `debug_fmt`, var `layer`, var `buf` are in scope.
|
||||
fn to_debug_match_arm(&self) -> TokenStream2 {
|
||||
let name = &self.name;
|
||||
let fields = &self.fields;
|
||||
let display = &self.display;
|
||||
let cfg = if let Some(cfg) = &self.cfg_attr {
|
||||
quote_spanned!(cfg.span() => #cfg)
|
||||
} else {
|
||||
quote! {}
|
||||
};
|
||||
|
||||
match (self.has_location, self.has_source, self.has_external_cause) {
|
||||
(true, true, _) => quote_spanned! {
|
||||
self.span => #cfg #[allow(unused_variables)] #name { #(#fields),*, } => {
|
||||
buf.push(format!("{layer}: {}, at {}", format!(#display), location));
|
||||
source.debug_fmt(layer + 1, buf);
|
||||
},
|
||||
},
|
||||
(true, false, true) => quote_spanned! {
|
||||
self.span => #cfg #[allow(unused_variables)] #name { #(#fields),* } => {
|
||||
buf.push(format!("{layer}: {}, at {}", format!(#display), location));
|
||||
buf.push(format!("{}: {:?}", layer + 1, error));
|
||||
},
|
||||
},
|
||||
(true, false, false) => quote_spanned! {
|
||||
self.span => #cfg #[allow(unused_variables)] #name { #(#fields),* } => {
|
||||
buf.push(format!("{layer}: {}, at {}", format!(#display), location));
|
||||
},
|
||||
},
|
||||
(false, true, _) => quote_spanned! {
|
||||
self.span => #cfg #[allow(unused_variables)] #name { #(#fields),* } => {
|
||||
buf.push(format!("{layer}: {}", format!(#display)));
|
||||
source.debug_fmt(layer + 1, buf);
|
||||
},
|
||||
},
|
||||
(false, false, true) => quote_spanned! {
|
||||
self.span => #cfg #[allow(unused_variables)] #name { #(#fields),* } => {
|
||||
buf.push(format!("{layer}: {}", format!(#display)));
|
||||
buf.push(format!("{}: {:?}", layer + 1, error));
|
||||
},
|
||||
},
|
||||
(false, false, false) => quote_spanned! {
|
||||
self.span => #cfg #[allow(unused_variables)] #name { #(#fields),* } => {
|
||||
buf.push(format!("{layer}: {}", format!(#display)));
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert self into an match arm that will be used in [build_next_impl].
|
||||
///
|
||||
/// The generated match arm will be like:
|
||||
/// ```rust, ignore
|
||||
/// ErrorKindWithSource { source, .. } => {
|
||||
/// Some(source)
|
||||
/// },
|
||||
/// ErrorKindWithoutSource { .. } => {
|
||||
/// None
|
||||
/// }
|
||||
/// ```
|
||||
fn to_next_match_arm(&self) -> TokenStream2 {
|
||||
let name = &self.name;
|
||||
let fields = &self.fields;
|
||||
let cfg = if let Some(cfg) = &self.cfg_attr {
|
||||
quote_spanned!(cfg.span() => #cfg)
|
||||
} else {
|
||||
quote! {}
|
||||
};
|
||||
|
||||
if self.has_source {
|
||||
quote_spanned! {
|
||||
self.span => #cfg #[allow(unused_variables)] #name { #(#fields),* } => {
|
||||
Some(source)
|
||||
},
|
||||
}
|
||||
} else {
|
||||
quote_spanned! {
|
||||
self.span => #cfg #[allow(unused_variables)] #name { #(#fields),* } =>{
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
snafu.workspace = true
|
||||
tempfile = "3.4"
|
||||
tokio.workspace = true
|
||||
|
||||
@@ -16,14 +16,16 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::Snafu;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display(""))]
|
||||
#[snafu(display("Internal error"))]
|
||||
Internal { source: BoxedError },
|
||||
|
||||
#[snafu(display("Memory profiling is not supported"))]
|
||||
|
||||
@@ -17,13 +17,18 @@ use std::path::PathBuf;
|
||||
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to read OPT_PROF"))]
|
||||
ReadOptProf { source: tikv_jemalloc_ctl::Error },
|
||||
ReadOptProf {
|
||||
#[snafu(source)]
|
||||
error: tikv_jemalloc_ctl::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Memory profiling is not enabled"))]
|
||||
ProfilingNotEnabled,
|
||||
@@ -34,13 +39,15 @@ pub enum Error {
|
||||
#[snafu(display("Failed to open temp file: {}", path))]
|
||||
OpenTempFile {
|
||||
path: String,
|
||||
source: std::io::Error,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to dump profiling data to temp file: {:?}", path))]
|
||||
DumpProfileData {
|
||||
path: PathBuf,
|
||||
source: tikv_jemalloc_ctl::Error,
|
||||
#[snafu(source)]
|
||||
error: tikv_jemalloc_ctl::Error,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ async-trait.workspace = true
|
||||
common-catalog = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-grpc-expr.workspace = true
|
||||
common-macro = { workspace = true }
|
||||
common-procedure = { workspace = true }
|
||||
common-recordbatch = { workspace = true }
|
||||
common-runtime = { workspace = true }
|
||||
|
||||
@@ -16,6 +16,7 @@ use std::str::Utf8Error;
|
||||
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use serde_json::error::Error as JsonError;
|
||||
use snafu::{Location, Snafu};
|
||||
use store_api::storage::RegionNumber;
|
||||
@@ -23,8 +24,9 @@ use table::metadata::TableId;
|
||||
|
||||
use crate::peer::Peer;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to get sequence: {}", err_msg))]
|
||||
NextSequence { err_msg: String, location: Location },
|
||||
@@ -83,7 +85,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to build table meta for table: {}", table_name))]
|
||||
BuildTableMeta {
|
||||
table_name: String,
|
||||
source: table::metadata::TableMetaBuilderError,
|
||||
#[snafu(source)]
|
||||
error: table::metadata::TableMetaBuilderError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -102,19 +105,22 @@ pub enum Error {
|
||||
#[snafu(display("Failed to decode protobuf"))]
|
||||
DecodeProto {
|
||||
location: Location,
|
||||
source: prost::DecodeError,
|
||||
#[snafu(source)]
|
||||
error: prost::DecodeError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to encode object into json"))]
|
||||
EncodeJson {
|
||||
location: Location,
|
||||
source: JsonError,
|
||||
#[snafu(source)]
|
||||
error: JsonError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to decode object from json"))]
|
||||
DecodeJson {
|
||||
location: Location,
|
||||
source: JsonError,
|
||||
#[snafu(source)]
|
||||
error: JsonError,
|
||||
},
|
||||
|
||||
#[snafu(display("Payload not exist"))]
|
||||
@@ -125,7 +131,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to serde json"))]
|
||||
SerdeJson {
|
||||
source: serde_json::error::Error,
|
||||
#[snafu(source)]
|
||||
error: serde_json::error::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -177,7 +184,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to convert raw key to str"))]
|
||||
ConvertRawKey {
|
||||
location: Location,
|
||||
source: Utf8Error,
|
||||
#[snafu(source)]
|
||||
error: Utf8Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Table nod found, table: {}", table_name))]
|
||||
|
||||
@@ -9,6 +9,7 @@ async-stream.workspace = true
|
||||
async-trait.workspace = true
|
||||
backon = "0.4"
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-runtime = { workspace = true }
|
||||
common-telemetry = { workspace = true }
|
||||
futures.workspace = true
|
||||
|
||||
@@ -18,13 +18,15 @@ use std::sync::Arc;
|
||||
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
use crate::procedure::ProcedureId;
|
||||
|
||||
/// Procedure error.
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to execute procedure due to external error"))]
|
||||
External { source: BoxedError },
|
||||
@@ -34,7 +36,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to serialize to json"))]
|
||||
ToJson {
|
||||
source: serde_json::Error,
|
||||
#[snafu(source)]
|
||||
error: serde_json::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -54,7 +57,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to delete {}", key))]
|
||||
DeleteState {
|
||||
key: String,
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to delete keys: '{keys}'"))]
|
||||
@@ -73,7 +77,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to deserialize from json"))]
|
||||
FromJson {
|
||||
source: serde_json::Error,
|
||||
#[snafu(source)]
|
||||
error: serde_json::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -85,7 +90,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to wait watcher"))]
|
||||
WaitWatcher {
|
||||
source: tokio::sync::watch::error::RecvError,
|
||||
#[snafu(source)]
|
||||
error: tokio::sync::watch::error::RecvError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -102,7 +108,10 @@ pub enum Error {
|
||||
},
|
||||
|
||||
#[snafu(display("Corrupted data, error: "))]
|
||||
CorruptedData { source: FromUtf8Error },
|
||||
CorruptedData {
|
||||
#[snafu(source)]
|
||||
error: FromUtf8Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to start the remove_outdated_meta method, error"))]
|
||||
StartRemoveOutdatedMetaTask {
|
||||
|
||||
@@ -229,7 +229,7 @@ impl ManagerContext {
|
||||
let procedure = loader(&message.data)
|
||||
.map_err(|e| {
|
||||
logging::error!(
|
||||
"Failed to load procedure data, key: {}, source: {}",
|
||||
"Failed to load procedure data, key: {}, source: {:?}",
|
||||
procedure_id,
|
||||
e
|
||||
);
|
||||
|
||||
@@ -224,7 +224,7 @@ impl ProcedureStore {
|
||||
serde_json::from_slice(value)
|
||||
.map_err(|e| {
|
||||
// `e` doesn't impl ErrorExt so we print it as normal error.
|
||||
logging::error!("Failed to parse value, key: {:?}, source: {}", key, e);
|
||||
logging::error!("Failed to parse value, key: {:?}, source: {:?}", key, e);
|
||||
e
|
||||
})
|
||||
.ok()
|
||||
|
||||
@@ -8,6 +8,7 @@ license.workspace = true
|
||||
api = { workspace = true }
|
||||
async-trait.workspace = true
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-recordbatch = { workspace = true }
|
||||
common-time = { workspace = true }
|
||||
datafusion-common.workspace = true
|
||||
|
||||
@@ -17,6 +17,7 @@ use std::any::Any;
|
||||
use arrow::error::ArrowError;
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use common_recordbatch::error::Error as RecordbatchError;
|
||||
use datafusion_common::DataFusionError;
|
||||
use datatypes::arrow;
|
||||
@@ -26,8 +27,9 @@ use datatypes::prelude::ConcreteDataType;
|
||||
use snafu::{Location, Snafu};
|
||||
use statrs::StatsError;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to execute Python UDF: {}", msg))]
|
||||
PyUdf {
|
||||
@@ -44,7 +46,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to execute function"))]
|
||||
ExecuteFunction {
|
||||
source: DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -57,7 +60,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to generate function"))]
|
||||
GenerateFunction {
|
||||
source: StatsError,
|
||||
#[snafu(source)]
|
||||
error: StatsError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -109,7 +113,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("General DataFusion error"))]
|
||||
GeneralDataFusion {
|
||||
source: DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -133,14 +138,16 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to cast array to {:?}", typ))]
|
||||
TypeCast {
|
||||
source: ArrowError,
|
||||
#[snafu(source)]
|
||||
error: ArrowError,
|
||||
typ: arrow::datatypes::DataType,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to perform compute operation on arrow arrays"))]
|
||||
ArrowCompute {
|
||||
source: ArrowError,
|
||||
#[snafu(source)]
|
||||
error: ArrowError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
datafusion-common.workspace = true
|
||||
datafusion.workspace = true
|
||||
datatypes = { workspace = true }
|
||||
|
||||
@@ -17,17 +17,20 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use datatypes::prelude::ConcreteDataType;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Fail to create datafusion record batch"))]
|
||||
NewDfRecordBatch {
|
||||
source: datatypes::arrow::error::ArrowError,
|
||||
#[snafu(source)]
|
||||
error: datatypes::arrow::error::ArrowError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -54,19 +57,22 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to poll stream"))]
|
||||
PollStream {
|
||||
source: datafusion::error::DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: datafusion::error::DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Fail to format record batch"))]
|
||||
Format {
|
||||
source: datatypes::arrow::error::ArrowError,
|
||||
#[snafu(source)]
|
||||
error: datatypes::arrow::error::ArrowError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to init Recordbatch stream"))]
|
||||
InitRecordbatchStream {
|
||||
source: datafusion_common::DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: datafusion_common::DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -76,7 +82,8 @@ pub enum Error {
|
||||
projection,
|
||||
))]
|
||||
ProjectArrowRecordBatch {
|
||||
source: datatypes::arrow::error::ArrowError,
|
||||
#[snafu(source)]
|
||||
error: datatypes::arrow::error::ArrowError,
|
||||
location: Location,
|
||||
schema: datatypes::schema::SchemaRef,
|
||||
projection: Vec<usize>,
|
||||
|
||||
@@ -7,6 +7,7 @@ license.workspace = true
|
||||
[dependencies]
|
||||
async-trait.workspace = true
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-telemetry = { workspace = true }
|
||||
metrics.workspace = true
|
||||
once_cell.workspace = true
|
||||
|
||||
@@ -15,17 +15,20 @@
|
||||
use std::any::Any;
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::{Location, Snafu};
|
||||
use tokio::task::JoinError;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub(crate)))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to build runtime"))]
|
||||
BuildRuntime {
|
||||
source: std::io::Error,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -35,7 +38,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to wait for repeated task {} to stop", name))]
|
||||
WaitGcTaskStop {
|
||||
name: String,
|
||||
source: JoinError,
|
||||
#[snafu(source)]
|
||||
error: JoinError,
|
||||
location: Location,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ bytes = "1.1"
|
||||
catalog = { workspace = true }
|
||||
common-catalog = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-telemetry = { workspace = true }
|
||||
datafusion-common.workspace = true
|
||||
datafusion-expr.workspace = true
|
||||
|
||||
@@ -16,13 +16,15 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use datafusion::error::DataFusionError;
|
||||
use datatypes::prelude::ConcreteDataType;
|
||||
use prost::{DecodeError, EncodeError};
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Unsupported physical plan: {}", name))]
|
||||
UnsupportedPlan { name: String, location: Location },
|
||||
@@ -41,13 +43,15 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to decode substrait relation"))]
|
||||
DecodeRel {
|
||||
source: DecodeError,
|
||||
#[snafu(source)]
|
||||
error: DecodeError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to encode substrait relation"))]
|
||||
EncodeRel {
|
||||
source: EncodeError,
|
||||
#[snafu(source)]
|
||||
error: EncodeError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -69,7 +73,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Internal error from DataFusion"))]
|
||||
DFInternal {
|
||||
source: DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -110,13 +115,15 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to encode DataFusion plan"))]
|
||||
EncodeDfPlan {
|
||||
source: datafusion::error::DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: datafusion::error::DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to decode DataFusion plan"))]
|
||||
DecodeDfPlan {
|
||||
source: datafusion::error::DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: datafusion::error::DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -39,93 +39,36 @@ macro_rules! error {
|
||||
// error!(e; target: "my_target", "a {} event", "log")
|
||||
($e:expr; target: $target:expr, $($arg:tt)+) => ({
|
||||
use $crate::common_error::ext::ErrorExt;
|
||||
use std::error::Error;
|
||||
match ($e.source(), $e.location_opt()) {
|
||||
(Some(source), Some(location)) => {
|
||||
$crate::log!(
|
||||
target: $target,
|
||||
$crate::logging::Level::ERROR,
|
||||
err.msg = %$e,
|
||||
err.code = %$e.status_code(),
|
||||
err.source = source,
|
||||
err.location = %location,
|
||||
$($arg)+
|
||||
)
|
||||
},
|
||||
(Some(source), None) => {
|
||||
$crate::log!(
|
||||
target: $target,
|
||||
$crate::logging::Level::ERROR,
|
||||
err.msg = %$e,
|
||||
err.code = %$e.status_code(),
|
||||
err.source = source,
|
||||
$($arg)+
|
||||
)
|
||||
},
|
||||
(None, Some(location)) => {
|
||||
$crate::log!(
|
||||
target: $target,
|
||||
$crate::logging::Level::ERROR,
|
||||
err.msg = %$e,
|
||||
err.code = %$e.status_code(),
|
||||
err.location = %location,
|
||||
$($arg)+
|
||||
)
|
||||
},
|
||||
(None, None) => {
|
||||
$crate::log!(
|
||||
target: $target,
|
||||
$crate::logging::Level::ERROR,
|
||||
err.msg = %$e,
|
||||
err.code = %$e.status_code(),
|
||||
$($arg)+
|
||||
)
|
||||
}
|
||||
}
|
||||
use $crate::common_error::ext::StackError;
|
||||
|
||||
let mut stacks = vec![];
|
||||
$e.debug_fmt(0, &mut stacks);
|
||||
let stacks = stacks.join("\n");
|
||||
|
||||
$crate::log!(
|
||||
target: $target,
|
||||
$crate::logging::Level::ERROR,
|
||||
err.msg = %stacks,
|
||||
err.code = %$e.status_code(),
|
||||
$($arg)+
|
||||
)
|
||||
});
|
||||
|
||||
// error!(e; "a {} event", "log")
|
||||
($e:expr; $($arg:tt)+) => ({
|
||||
use std::error::Error;
|
||||
use $crate::common_error::ext::ErrorExt;
|
||||
match ($e.source(), $e.location_opt()) {
|
||||
(Some(source), Some(location)) => {
|
||||
$crate::log!(
|
||||
$crate::logging::Level::ERROR,
|
||||
err.msg = %$e,
|
||||
err.code = %$e.status_code(),
|
||||
err.source = source,
|
||||
err.location = %location,
|
||||
$($arg)+
|
||||
)
|
||||
},
|
||||
(Some(source), None) => {
|
||||
$crate::log!(
|
||||
$crate::logging::Level::ERROR,
|
||||
err.msg = %$e,
|
||||
err.code = %$e.status_code(),
|
||||
err.source = source,
|
||||
$($arg)+
|
||||
)
|
||||
},
|
||||
(None, Some(location)) => {
|
||||
$crate::log!(
|
||||
$crate::logging::Level::ERROR,
|
||||
err.msg = %$e,
|
||||
err.code = %$e.status_code(),
|
||||
err.location = %location,
|
||||
$($arg)+
|
||||
)
|
||||
},
|
||||
(None, None) => {
|
||||
$crate::log!(
|
||||
$crate::logging::Level::ERROR,
|
||||
err.msg = %$e,
|
||||
err.code = %$e.status_code(),
|
||||
$($arg)+
|
||||
)
|
||||
}
|
||||
}
|
||||
use $crate::common_error::ext::StackError;
|
||||
|
||||
let mut stacks = vec![];
|
||||
$e.debug_fmt(0, &mut stacks);
|
||||
let stacks = stacks.join("\n");
|
||||
|
||||
$crate::log!(
|
||||
$crate::logging::Level::ERROR,
|
||||
err.msg = %stacks,
|
||||
err.code = %$e.status_code(),
|
||||
$($arg)+
|
||||
)
|
||||
});
|
||||
|
||||
// error!("a {} event", "log")
|
||||
@@ -144,46 +87,19 @@ macro_rules! warn {
|
||||
|
||||
// warn!(e; "a {} event", "log")
|
||||
($e:expr; $($arg:tt)+) => ({
|
||||
use std::error::Error;
|
||||
use $crate::common_error::ext::ErrorExt;
|
||||
match ($e.source(), $e.location_opt()) {
|
||||
(Some(source), Some(location)) => {
|
||||
$crate::log!(
|
||||
$crate::logging::Level::WARN,
|
||||
err.msg = %$e,
|
||||
err.code = %$e.status_code(),
|
||||
err.source = source,
|
||||
err.location = %location,
|
||||
$($arg)+
|
||||
)
|
||||
},
|
||||
(Some(source), None) => {
|
||||
$crate::log!(
|
||||
$crate::logging::Level::WARN,
|
||||
err.msg = %$e,
|
||||
err.code = %$e.status_code(),
|
||||
err.source = source,
|
||||
$($arg)+
|
||||
)
|
||||
},
|
||||
(None, Some(location)) => {
|
||||
$crate::log!(
|
||||
$crate::logging::Level::WARN,
|
||||
err.msg = %$e,
|
||||
err.code = %$e.status_code(),
|
||||
err.location = %location,
|
||||
$($arg)+
|
||||
)
|
||||
},
|
||||
(None, None) => {
|
||||
$crate::log!(
|
||||
$crate::logging::Level::WARN,
|
||||
err.msg = %$e,
|
||||
err.code = %$e.status_code(),
|
||||
$($arg)+
|
||||
)
|
||||
}
|
||||
}
|
||||
use $crate::common_error::ext::StackError;
|
||||
|
||||
let mut stacks = vec![];
|
||||
$e.debug_fmt(0, &mut stacks);
|
||||
let stacks = stacks.join("\n");
|
||||
|
||||
$crate::log!(
|
||||
$crate::logging::Level::WARN,
|
||||
err.msg = %$e,
|
||||
err.code = %$e.status_code(),
|
||||
$($arg)+
|
||||
)
|
||||
});
|
||||
|
||||
// warn!("a {} event", "log")
|
||||
|
||||
@@ -9,6 +9,7 @@ arrow.workspace = true
|
||||
chrono-tz = "0.8"
|
||||
chrono.workspace = true
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
snafu = { version = "0.7", features = ["backtraces"] }
|
||||
|
||||
@@ -18,13 +18,19 @@ use std::num::{ParseIntError, TryFromIntError};
|
||||
use chrono::ParseError;
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to parse string to date, raw: {}", raw))]
|
||||
ParseDateStr { raw: String, source: ParseError },
|
||||
ParseDateStr {
|
||||
raw: String,
|
||||
#[snafu(source)]
|
||||
error: ParseError,
|
||||
},
|
||||
|
||||
#[snafu(display("Invalid date string, raw: {}", raw))]
|
||||
InvalidDateStr { raw: String, location: Location },
|
||||
@@ -37,7 +43,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Current timestamp overflow"))]
|
||||
TimestampOverflow {
|
||||
source: TryFromIntError,
|
||||
#[snafu(source)]
|
||||
error: TryFromIntError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -54,7 +61,8 @@ pub enum Error {
|
||||
#[snafu(display("Invalid offset string {raw}: "))]
|
||||
ParseOffsetStr {
|
||||
raw: String,
|
||||
source: ParseIntError,
|
||||
#[snafu(source)]
|
||||
error: ParseIntError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ common-function = { workspace = true }
|
||||
common-greptimedb-telemetry = { workspace = true }
|
||||
common-grpc = { workspace = true }
|
||||
common-grpc-expr = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-meta = { workspace = true }
|
||||
common-procedure = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
|
||||
@@ -16,6 +16,7 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use common_procedure::ProcedureId;
|
||||
use serde_json::error::Error as JsonError;
|
||||
use servers::define_into_tonic_status;
|
||||
@@ -24,8 +25,9 @@ use store_api::storage::RegionId;
|
||||
use table::error::Error as TableError;
|
||||
|
||||
/// Business error of datanode.
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to handle heartbeat response"))]
|
||||
HandleHeartbeatResponse {
|
||||
@@ -170,14 +172,23 @@ pub enum Error {
|
||||
#[snafu(display("Failed to parse address {}", addr))]
|
||||
ParseAddr {
|
||||
addr: String,
|
||||
source: std::net::AddrParseError,
|
||||
#[snafu(source)]
|
||||
error: std::net::AddrParseError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to create directory {}", dir))]
|
||||
CreateDir { dir: String, source: std::io::Error },
|
||||
CreateDir {
|
||||
dir: String,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to remove directory {}", dir))]
|
||||
RemoveDir { dir: String, source: std::io::Error },
|
||||
RemoveDir {
|
||||
dir: String,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to open log store"))]
|
||||
OpenLogStore {
|
||||
@@ -187,7 +198,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to init backend"))]
|
||||
InitBackend {
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -340,7 +352,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to encode object into json"))]
|
||||
EncodeJson {
|
||||
location: Location,
|
||||
source: JsonError,
|
||||
#[snafu(source)]
|
||||
error: JsonError,
|
||||
},
|
||||
|
||||
#[snafu(display("Payload not exist"))]
|
||||
@@ -351,7 +364,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to join task"))]
|
||||
JoinTask {
|
||||
source: common_runtime::JoinError,
|
||||
#[snafu(source)]
|
||||
error: common_runtime::JoinError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ arrow-schema.workspace = true
|
||||
arrow.workspace = true
|
||||
common-base = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-telemetry = { workspace = true }
|
||||
common-time = { workspace = true }
|
||||
datafusion-common.workspace = true
|
||||
|
||||
@@ -16,20 +16,24 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to serialize data"))]
|
||||
Serialize {
|
||||
source: serde_json::Error,
|
||||
#[snafu(source)]
|
||||
error: serde_json::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to deserialize data, json: {}", json))]
|
||||
Deserialize {
|
||||
source: serde_json::Error,
|
||||
#[snafu(source)]
|
||||
error: serde_json::Error,
|
||||
location: Location,
|
||||
json: String,
|
||||
},
|
||||
@@ -63,7 +67,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to parse version in schema meta, value: {}", value))]
|
||||
ParseSchemaVersion {
|
||||
value: String,
|
||||
source: std::num::ParseIntError,
|
||||
#[snafu(source)]
|
||||
error: std::num::ParseIntError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -75,19 +80,22 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to cast arrow time i32 type into i64"))]
|
||||
CastTimeType {
|
||||
source: std::num::TryFromIntError,
|
||||
#[snafu(source)]
|
||||
error: std::num::TryFromIntError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Arrow failed to compute"))]
|
||||
ArrowCompute {
|
||||
source: arrow::error::ArrowError,
|
||||
#[snafu(source)]
|
||||
error: arrow::error::ArrowError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to project arrow schema"))]
|
||||
ProjectArrowSchema {
|
||||
source: arrow::error::ArrowError,
|
||||
#[snafu(source)]
|
||||
error: arrow::error::ArrowError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ async-trait = "0.1"
|
||||
common-catalog = { workspace = true }
|
||||
common-datasource = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-procedure = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
common-recordbatch = { workspace = true }
|
||||
|
||||
@@ -16,14 +16,16 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use datafusion::arrow::error::ArrowError;
|
||||
use datafusion::error::DataFusionError;
|
||||
use serde_json::error::Error as JsonError;
|
||||
use snafu::{Location, Snafu};
|
||||
use store_api::storage::RegionId;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Unsupported operation: {}", operation))]
|
||||
Unsupported {
|
||||
@@ -50,38 +52,44 @@ pub enum Error {
|
||||
CheckObject {
|
||||
path: String,
|
||||
location: Location,
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Fail to encode object into json"))]
|
||||
EncodeJson {
|
||||
location: Location,
|
||||
source: JsonError,
|
||||
#[snafu(source)]
|
||||
error: JsonError,
|
||||
},
|
||||
|
||||
#[snafu(display("Fail to decode object from json"))]
|
||||
DecodeJson {
|
||||
location: Location,
|
||||
source: JsonError,
|
||||
#[snafu(source)]
|
||||
error: JsonError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to store region manifest, region_id: {}", region_id))]
|
||||
StoreRegionManifest {
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
region_id: RegionId,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to load region manifest, region_id: {}", region_id))]
|
||||
LoadRegionManifest {
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
region_id: RegionId,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to delete region manifest, region_id: {},", region_id))]
|
||||
DeleteRegionManifest {
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
region_id: RegionId,
|
||||
location: Location,
|
||||
},
|
||||
@@ -100,19 +108,22 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to build csv config"))]
|
||||
BuildCsvConfig {
|
||||
source: common_datasource::file_format::csv::CsvConfigBuilderError,
|
||||
#[snafu(source)]
|
||||
error: common_datasource::file_format::csv::CsvConfigBuilderError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to build stream"))]
|
||||
BuildStream {
|
||||
source: DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to project schema"))]
|
||||
ProjectArrowSchema {
|
||||
source: ArrowError,
|
||||
#[snafu(source)]
|
||||
error: ArrowError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -136,7 +147,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to generate parquet scan plan"))]
|
||||
ParquetScanPlan {
|
||||
source: DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -153,7 +165,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to extract column from filter"))]
|
||||
ExtractColumnFromFilter {
|
||||
source: DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ common-error = { workspace = true }
|
||||
common-function = { workspace = true }
|
||||
common-grpc = { workspace = true }
|
||||
common-grpc-expr = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-meta = { workspace = true }
|
||||
common-procedure = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
|
||||
+37
-35
@@ -17,12 +17,14 @@ use std::any::Any;
|
||||
use common_datasource::file_format::Format;
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use servers::define_into_tonic_status;
|
||||
use snafu::{Location, Snafu};
|
||||
use store_api::storage::RegionNumber;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to invalidate table cache"))]
|
||||
InvalidateTableCache {
|
||||
@@ -44,43 +46,44 @@ pub enum Error {
|
||||
|
||||
#[snafu(display(""))]
|
||||
External {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: BoxedError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to query"))]
|
||||
RequestQuery {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: common_meta::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Runtime resource error"))]
|
||||
RuntimeResource {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: common_runtime::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to start server"))]
|
||||
StartServer {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: servers::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to shutdown server"))]
|
||||
ShutdownServer {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: servers::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse address {}", addr))]
|
||||
ParseAddr {
|
||||
addr: String,
|
||||
source: std::net::AddrParseError,
|
||||
#[snafu(source)]
|
||||
error: std::net::AddrParseError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse SQL"))]
|
||||
ParseSql {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: sql::error::Error,
|
||||
},
|
||||
|
||||
@@ -113,13 +116,13 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("General catalog error"))]
|
||||
Catalog {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: catalog::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to start Meta client"))]
|
||||
StartMetaClient {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: meta_client::error::Error,
|
||||
},
|
||||
|
||||
@@ -132,7 +135,7 @@ pub enum Error {
|
||||
#[snafu(display("Failed to find table route for table id {}", table_id))]
|
||||
FindTableRoute {
|
||||
table_id: u32,
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: partition::error::Error,
|
||||
},
|
||||
|
||||
@@ -141,7 +144,7 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Table occurs error"))]
|
||||
Table {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: table::error::Error,
|
||||
},
|
||||
|
||||
@@ -150,26 +153,26 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to plan statement"))]
|
||||
PlanStatement {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to read table: {table_name}"))]
|
||||
ReadTable {
|
||||
table_name: String,
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to execute logical plan"))]
|
||||
ExecLogicalPlan {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display(""))]
|
||||
InvokeRegionServer {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: servers::error::Error,
|
||||
},
|
||||
|
||||
@@ -190,7 +193,7 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("SQL execution intercepted"))]
|
||||
SqlExecIntercepted {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: BoxedError,
|
||||
},
|
||||
|
||||
@@ -198,19 +201,19 @@ pub enum Error {
|
||||
#[snafu(display("Failed to execute PromQL query {}", query))]
|
||||
ExecutePromql {
|
||||
query: String,
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: servers::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to create logical plan for prometheus query"))]
|
||||
PromStoreRemoteQueryPlan {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: servers::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to describe schema for given statement"))]
|
||||
DescribeStatement {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
@@ -219,21 +222,21 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to start script manager"))]
|
||||
StartScriptManager {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: script::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to copy table: {}", table_name))]
|
||||
CopyTable {
|
||||
table_name: String,
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: table::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to insert value into table: {}", table_name))]
|
||||
Insert {
|
||||
table_name: String,
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: table::error::Error,
|
||||
},
|
||||
|
||||
@@ -293,7 +296,7 @@ impl ErrorExt for Error {
|
||||
|
||||
Error::Permission { source, .. } => source.status_code(),
|
||||
|
||||
Error::DescribeStatement { source } => source.status_code(),
|
||||
Error::DescribeStatement { source, .. } => source.status_code(),
|
||||
|
||||
Error::HandleHeartbeatResponse { source, .. }
|
||||
| Error::TableMetadataManager { source, .. } => source.status_code(),
|
||||
@@ -306,17 +309,17 @@ impl ErrorExt for Error {
|
||||
Error::StartServer { source, .. } => source.status_code(),
|
||||
Error::ShutdownServer { source, .. } => source.status_code(),
|
||||
|
||||
Error::ParseSql { source } => source.status_code(),
|
||||
Error::ParseSql { source, .. } => source.status_code(),
|
||||
|
||||
Error::InvalidateTableCache { source, .. } => source.status_code(),
|
||||
|
||||
Error::Table { source }
|
||||
Error::Table { source, .. }
|
||||
| Error::CopyTable { source, .. }
|
||||
| Error::Insert { source, .. } => source.status_code(),
|
||||
|
||||
Error::OpenRaftEngineBackend { .. } => StatusCode::StorageUnavailable,
|
||||
|
||||
Error::RequestQuery { source } => source.status_code(),
|
||||
Error::RequestQuery { source, .. } => source.status_code(),
|
||||
|
||||
Error::FindDatanode { .. }
|
||||
| Error::VectorToGrpcColumn { .. }
|
||||
@@ -330,22 +333,21 @@ impl ErrorExt for Error {
|
||||
|
||||
Error::Catalog { source, .. } => source.status_code(),
|
||||
|
||||
Error::StartMetaClient { source } | Error::CreateMetaHeartbeatStream { source, .. } => {
|
||||
source.status_code()
|
||||
}
|
||||
Error::StartMetaClient { source, .. }
|
||||
| Error::CreateMetaHeartbeatStream { source, .. } => source.status_code(),
|
||||
|
||||
Error::PlanStatement { source }
|
||||
Error::PlanStatement { source, .. }
|
||||
| Error::ReadTable { source, .. }
|
||||
| Error::ExecLogicalPlan { source } => source.status_code(),
|
||||
| Error::ExecLogicalPlan { source, .. } => source.status_code(),
|
||||
|
||||
Error::LeaderNotFound { .. } => StatusCode::StorageUnavailable,
|
||||
Error::TableAlreadyExist { .. } => StatusCode::TableAlreadyExists,
|
||||
Error::InvokeRegionServer { source } => source.status_code(),
|
||||
Error::InvokeRegionServer { source, .. } => source.status_code(),
|
||||
|
||||
Error::External { source } => source.status_code(),
|
||||
Error::External { source, .. } => source.status_code(),
|
||||
Error::FindTableRoute { source, .. } => source.status_code(),
|
||||
|
||||
Error::StartScriptManager { source } => source.status_code(),
|
||||
Error::StartScriptManager { source, .. } => source.status_code(),
|
||||
|
||||
Error::TableOperation { source, .. } => source.status_code(),
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ use common_base::Plugins;
|
||||
use common_runtime::Builder as RuntimeBuilder;
|
||||
use common_telemetry::info;
|
||||
use servers::configurator::ConfiguratorRef;
|
||||
use servers::error::Error::InternalIo;
|
||||
use servers::error::InternalIoSnafu;
|
||||
use servers::grpc::{GrpcServer, GrpcServerConfig};
|
||||
use servers::http::HttpServerBuilder;
|
||||
use servers::metrics_handler::MetricsHandler;
|
||||
@@ -33,8 +33,7 @@ use servers::query_handler::sql::ServerSqlQueryHandlerAdaptor;
|
||||
use servers::server::Server;
|
||||
use snafu::ResultExt;
|
||||
|
||||
use crate::error::Error::StartServer;
|
||||
use crate::error::{self, Result};
|
||||
use crate::error::{self, Result, StartServerSnafu};
|
||||
use crate::frontend::FrontendOptions;
|
||||
use crate::instance::FrontendInstance;
|
||||
|
||||
@@ -149,9 +148,8 @@ impl Services {
|
||||
opts.tls.should_force_tls(),
|
||||
opts.tls
|
||||
.setup()
|
||||
.map_err(|e| StartServer {
|
||||
source: InternalIo { source: e },
|
||||
})?
|
||||
.context(InternalIoSnafu)
|
||||
.context(StartServerSnafu)?
|
||||
.map(Arc::new),
|
||||
opts.reject_no_database.unwrap_or(false),
|
||||
)),
|
||||
|
||||
@@ -18,6 +18,7 @@ bytes = "1.1"
|
||||
common-base = { workspace = true }
|
||||
common-config = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-meta = { workspace = true }
|
||||
common-runtime = { workspace = true }
|
||||
common-telemetry = { workspace = true }
|
||||
|
||||
@@ -15,11 +15,13 @@
|
||||
use std::any::Any;
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_macro::stack_trace_debug;
|
||||
use common_runtime::error::Error as RuntimeError;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to start log store gc task"))]
|
||||
StartGcTask {
|
||||
@@ -35,13 +37,15 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to add entry to LogBatch"))]
|
||||
AddEntryLogBatch {
|
||||
source: raft_engine::Error,
|
||||
#[snafu(source)]
|
||||
error: raft_engine::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to perform raft-engine operation"))]
|
||||
RaftEngine {
|
||||
source: raft_engine::Error,
|
||||
#[snafu(source)]
|
||||
error: raft_engine::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -63,7 +67,8 @@ pub enum Error {
|
||||
start: u64,
|
||||
end: u64,
|
||||
max_size: usize,
|
||||
source: raft_engine::Error,
|
||||
#[snafu(source)]
|
||||
error: raft_engine::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ async-trait = "0.1"
|
||||
chrono.workspace = true
|
||||
common-error = { workspace = true }
|
||||
common-grpc = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-meta = { workspace = true }
|
||||
common-telemetry = { workspace = true }
|
||||
etcd-client.workspace = true
|
||||
|
||||
@@ -15,11 +15,13 @@
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_error::{GREPTIME_ERROR_CODE, GREPTIME_ERROR_MSG};
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::{Location, Snafu};
|
||||
use tonic::Status;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Illegal GRPC client state: {}", err_msg))]
|
||||
IllegalGrpcClientState { err_msg: String, location: Location },
|
||||
@@ -36,7 +38,8 @@ pub enum Error {
|
||||
#[snafu(display("Ask leader timeout"))]
|
||||
AskLeaderTimeout {
|
||||
location: Location,
|
||||
source: tokio::time::error::Elapsed,
|
||||
#[snafu(source)]
|
||||
error: tokio::time::error::Elapsed,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to create gRPC channel"))]
|
||||
|
||||
@@ -20,6 +20,7 @@ common-error = { workspace = true }
|
||||
common-greptimedb-telemetry = { workspace = true }
|
||||
common-grpc = { workspace = true }
|
||||
common-grpc-expr = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-meta = { workspace = true }
|
||||
common-procedure = { workspace = true }
|
||||
common-runtime = { workspace = true }
|
||||
|
||||
@@ -256,8 +256,8 @@ fn check_resp_header(header: &Option<ResponseHeader>, ctx: Context) -> Result<()
|
||||
fn need_retry(error: &error::Error) -> bool {
|
||||
match error {
|
||||
error::Error::IsNotLeader { .. } => true,
|
||||
error::Error::Range { source, .. } | error::Error::BatchGet { source, .. } => {
|
||||
match_for_io_error(source).is_some()
|
||||
error::Error::Range { error, .. } | error::Error::BatchGet { error, .. } => {
|
||||
match_for_io_error(error).is_some()
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
|
||||
+53
-25
@@ -14,6 +14,7 @@
|
||||
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use common_meta::peer::Peer;
|
||||
use common_runtime::JoinError;
|
||||
use servers::define_into_tonic_status;
|
||||
@@ -24,8 +25,9 @@ use tonic::codegen::http;
|
||||
|
||||
use crate::pubsub::Message;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to create default catalog and schema"))]
|
||||
InitMetadata {
|
||||
@@ -74,7 +76,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to join a future"))]
|
||||
Join {
|
||||
location: Location,
|
||||
source: JoinError,
|
||||
#[snafu(source)]
|
||||
error: JoinError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to execute transaction: {}", msg))]
|
||||
@@ -110,7 +113,10 @@ pub enum Error {
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to send shutdown signal"))]
|
||||
SendShutdownSignal { source: SendError<()> },
|
||||
SendShutdownSignal {
|
||||
#[snafu(source)]
|
||||
error: SendError<()>,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to shutdown {} server", server))]
|
||||
ShutdownServer {
|
||||
@@ -124,26 +130,30 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to execute via Etcd"))]
|
||||
EtcdFailed {
|
||||
source: etcd_client::Error,
|
||||
#[snafu(source)]
|
||||
error: etcd_client::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to connect to Etcd"))]
|
||||
ConnectEtcd {
|
||||
source: etcd_client::Error,
|
||||
#[snafu(source)]
|
||||
error: etcd_client::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to bind address {}", addr))]
|
||||
TcpBind {
|
||||
addr: String,
|
||||
source: std::io::Error,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to start gRPC server"))]
|
||||
StartGrpc {
|
||||
source: tonic::transport::Error,
|
||||
#[snafu(source)]
|
||||
error: tonic::transport::Error,
|
||||
location: Location,
|
||||
},
|
||||
#[snafu(display("Failed to start http server"))]
|
||||
@@ -154,7 +164,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to parse address {}", addr))]
|
||||
ParseAddr {
|
||||
addr: String,
|
||||
source: std::net::AddrParseError,
|
||||
#[snafu(source)]
|
||||
error: std::net::AddrParseError,
|
||||
},
|
||||
#[snafu(display("Empty table name"))]
|
||||
EmptyTableName { location: Location },
|
||||
@@ -170,52 +181,60 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to parse datanode lease key from utf8"))]
|
||||
LeaseKeyFromUtf8 {
|
||||
source: std::string::FromUtf8Error,
|
||||
#[snafu(source)]
|
||||
error: std::string::FromUtf8Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse datanode lease value from utf8"))]
|
||||
LeaseValueFromUtf8 {
|
||||
source: std::string::FromUtf8Error,
|
||||
#[snafu(source)]
|
||||
error: std::string::FromUtf8Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse datanode stat key from utf8"))]
|
||||
StatKeyFromUtf8 {
|
||||
source: std::string::FromUtf8Error,
|
||||
#[snafu(source)]
|
||||
error: std::string::FromUtf8Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse datanode stat value from utf8"))]
|
||||
StatValueFromUtf8 {
|
||||
source: std::string::FromUtf8Error,
|
||||
#[snafu(source)]
|
||||
error: std::string::FromUtf8Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse invalid region key from utf8"))]
|
||||
InvalidRegionKeyFromUtf8 {
|
||||
source: std::string::FromUtf8Error,
|
||||
#[snafu(source)]
|
||||
error: std::string::FromUtf8Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to serialize to json: {}", input))]
|
||||
SerializeToJson {
|
||||
input: String,
|
||||
source: serde_json::error::Error,
|
||||
#[snafu(source)]
|
||||
error: serde_json::error::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to deserialize from json: {}", input))]
|
||||
DeserializeFromJson {
|
||||
input: String,
|
||||
source: serde_json::error::Error,
|
||||
#[snafu(source)]
|
||||
error: serde_json::error::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse number: {}", err_msg))]
|
||||
ParseNum {
|
||||
err_msg: String,
|
||||
source: std::num::ParseIntError,
|
||||
#[snafu(source)]
|
||||
error: std::num::ParseIntError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -239,7 +258,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to decode table route"))]
|
||||
DecodeTableRoute {
|
||||
source: prost::DecodeError,
|
||||
#[snafu(source)]
|
||||
error: prost::DecodeError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -294,13 +314,15 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to batch get KVs from leader's in_memory kv store"))]
|
||||
BatchGet {
|
||||
source: tonic::Status,
|
||||
#[snafu(source)]
|
||||
error: tonic::Status,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to batch range KVs from leader's in_memory kv store"))]
|
||||
Range {
|
||||
source: tonic::Status,
|
||||
#[snafu(source)]
|
||||
error: tonic::Status,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -315,7 +337,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Invalid http body"))]
|
||||
InvalidHttpBody {
|
||||
source: http::Error,
|
||||
#[snafu(source)]
|
||||
error: http::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -332,19 +355,22 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to lock based on etcd"))]
|
||||
Lock {
|
||||
source: etcd_client::Error,
|
||||
#[snafu(source)]
|
||||
error: etcd_client::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to unlock based on etcd"))]
|
||||
Unlock {
|
||||
source: etcd_client::Error,
|
||||
#[snafu(source)]
|
||||
error: etcd_client::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to grant lease"))]
|
||||
LeaseGrant {
|
||||
source: etcd_client::Error,
|
||||
#[snafu(source)]
|
||||
error: etcd_client::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -353,7 +379,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Invalid utf-8 value"))]
|
||||
InvalidUtf8Value {
|
||||
source: std::string::FromUtf8Error,
|
||||
#[snafu(source)]
|
||||
error: std::string::FromUtf8Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -494,7 +521,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to publish message"))]
|
||||
PublishMessage {
|
||||
source: SendError<Message>,
|
||||
#[snafu(source)]
|
||||
error: SendError<Message>,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ common-base = { workspace = true }
|
||||
common-catalog = { workspace = true }
|
||||
common-datasource = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-procedure = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
common-recordbatch = { workspace = true }
|
||||
|
||||
+40
-20
@@ -18,6 +18,7 @@ use std::sync::Arc;
|
||||
use common_datasource::compression::CompressionType;
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use common_runtime::JoinError;
|
||||
use datatypes::arrow::error::ArrowError;
|
||||
use datatypes::prelude::ConcreteDataType;
|
||||
@@ -29,33 +30,38 @@ use store_api::storage::RegionId;
|
||||
use crate::sst::file::FileId;
|
||||
use crate::worker::WorkerId;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("OpenDAL operator failed"))]
|
||||
OpenDal {
|
||||
location: Location,
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Fail to compress object by {}, path: {}", compress_type, path))]
|
||||
CompressObject {
|
||||
compress_type: CompressionType,
|
||||
path: String,
|
||||
source: std::io::Error,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Fail to decompress object by {}, path: {}", compress_type, path))]
|
||||
DecompressObject {
|
||||
compress_type: CompressionType,
|
||||
path: String,
|
||||
source: std::io::Error,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to ser/de json object"))]
|
||||
SerdeJson {
|
||||
location: Location,
|
||||
source: serde_json::Error,
|
||||
#[snafu(source)]
|
||||
error: serde_json::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Invalid scan index, start: {}, end: {}", start, end))]
|
||||
@@ -68,7 +74,8 @@ pub enum Error {
|
||||
#[snafu(display("Invalid UTF-8 content"))]
|
||||
Utf8 {
|
||||
location: Location,
|
||||
source: std::str::Utf8Error,
|
||||
#[snafu(source)]
|
||||
error: std::str::Utf8Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Cannot find RegionMetadata"))]
|
||||
@@ -76,7 +83,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to join handle"))]
|
||||
Join {
|
||||
source: common_runtime::JoinError,
|
||||
#[snafu(source)]
|
||||
error: common_runtime::JoinError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -85,7 +93,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to recv result"))]
|
||||
Recv {
|
||||
source: tokio::sync::oneshot::error::RecvError,
|
||||
#[snafu(source)]
|
||||
error: tokio::sync::oneshot::error::RecvError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -101,7 +110,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to create RecordBatch from vectors"))]
|
||||
NewRecordBatch {
|
||||
location: Location,
|
||||
source: ArrowError,
|
||||
#[snafu(source)]
|
||||
error: ArrowError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to write to buffer"))]
|
||||
@@ -114,13 +124,15 @@ pub enum Error {
|
||||
WriteParquet {
|
||||
path: String,
|
||||
location: Location,
|
||||
source: parquet::errors::ParquetError,
|
||||
#[snafu(source)]
|
||||
error: parquet::errors::ParquetError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to read parquet file, path: {}", path))]
|
||||
ReadParquet {
|
||||
path: String,
|
||||
source: parquet::errors::ParquetError,
|
||||
#[snafu(source)]
|
||||
error: parquet::errors::ParquetError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -167,7 +179,8 @@ pub enum Error {
|
||||
EncodeWal {
|
||||
region_id: RegionId,
|
||||
location: Location,
|
||||
source: EncodeError,
|
||||
#[snafu(source)]
|
||||
error: EncodeError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to write WAL"))]
|
||||
@@ -187,7 +200,8 @@ pub enum Error {
|
||||
DecodeWal {
|
||||
region_id: RegionId,
|
||||
location: Location,
|
||||
source: DecodeError,
|
||||
#[snafu(source)]
|
||||
error: DecodeError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to delete WAL, region_id: {}", region_id))]
|
||||
@@ -206,7 +220,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to serialize field"))]
|
||||
SerializeField {
|
||||
source: memcomparable::Error,
|
||||
#[snafu(source)]
|
||||
error: memcomparable::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -221,7 +236,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to deserialize field"))]
|
||||
DeserializeField {
|
||||
source: memcomparable::Error,
|
||||
#[snafu(source)]
|
||||
error: memcomparable::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -247,7 +263,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to compute arrow arrays"))]
|
||||
ComputeArrow {
|
||||
location: Location,
|
||||
source: datatypes::arrow::error::ArrowError,
|
||||
#[snafu(source)]
|
||||
error: datatypes::arrow::error::ArrowError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to compute vector"))]
|
||||
@@ -271,7 +288,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to stop scheduler"))]
|
||||
StopScheduler {
|
||||
source: JoinError,
|
||||
#[snafu(source)]
|
||||
error: JoinError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -284,7 +302,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to delete SST file, file id: {}", file_id))]
|
||||
DeleteSst {
|
||||
file_id: FileId,
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -352,9 +371,10 @@ pub enum Error {
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Invalid options, source: {}", source))]
|
||||
#[snafu(display("Invalid options"))]
|
||||
JsonOptions {
|
||||
source: serde_json::Error,
|
||||
#[snafu(source)]
|
||||
error: serde_json::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ common-catalog = { workspace = true }
|
||||
common-datasource = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-grpc-expr = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-meta = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
common-recordbatch = { workspace = true }
|
||||
|
||||
+80
-66
@@ -17,14 +17,16 @@ use std::any::Any;
|
||||
use common_datasource::file_format::Format;
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use datafusion::parquet;
|
||||
use datatypes::arrow::error::ArrowError;
|
||||
use datatypes::value::Value;
|
||||
use servers::define_into_tonic_status;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to invalidate table cache"))]
|
||||
InvalidateTableCache {
|
||||
@@ -46,52 +48,52 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("external error"))]
|
||||
External {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: BoxedError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to insert data"))]
|
||||
RequestInserts {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: common_meta::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to delete data"))]
|
||||
RequestDeletes {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: common_meta::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse SQL"))]
|
||||
ParseSql {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: sql::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to convert value to sql value: {}", value))]
|
||||
ConvertSqlValue {
|
||||
value: Value,
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: sql::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Column datatype error"))]
|
||||
ColumnDataType {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: api::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Invalid column proto definition, column: {}", column))]
|
||||
InvalidColumnDef {
|
||||
column: String,
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: api::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to convert column default constraint, column: {}", column_name))]
|
||||
ConvertColumnDefaultConstraint {
|
||||
column_name: String,
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: datatypes::error::Error,
|
||||
},
|
||||
|
||||
@@ -109,20 +111,21 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to join task"))]
|
||||
JoinTask {
|
||||
source: common_runtime::JoinError,
|
||||
#[snafu(source)]
|
||||
error: common_runtime::JoinError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("General catalog error"))]
|
||||
Catalog {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: catalog::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to find table partition rule for table {}", table_name))]
|
||||
FindTablePartitionRule {
|
||||
table_name: String,
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: partition::error::Error,
|
||||
},
|
||||
|
||||
@@ -146,13 +149,13 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to create table info"))]
|
||||
CreateTableInfo {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: datatypes::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to build CreateExpr on insertion"))]
|
||||
BuildCreateExprOnInsertion {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: common_grpc_expr::error::Error,
|
||||
},
|
||||
|
||||
@@ -167,7 +170,7 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Table occurs error"))]
|
||||
Table {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: table::error::Error,
|
||||
},
|
||||
|
||||
@@ -176,44 +179,46 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to execute statement"))]
|
||||
ExecuteStatement {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to plan statement"))]
|
||||
PlanStatement {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse query"))]
|
||||
ParseQuery {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to execute logical plan"))]
|
||||
ExecLogicalPlan {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to build DataFusion logical plan"))]
|
||||
BuildDfLogicalPlan {
|
||||
source: datafusion_common::DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: datafusion_common::DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to convert AlterExpr to AlterRequest"))]
|
||||
AlterExprToRequest {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: common_grpc_expr::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to build table meta for table: {}", table_name))]
|
||||
BuildTableMeta {
|
||||
table_name: String,
|
||||
source: table::metadata::TableMetaBuilderError,
|
||||
#[snafu(source)]
|
||||
error: table::metadata::TableMetaBuilderError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -222,25 +227,25 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to find new columns on insertion"))]
|
||||
FindNewColumnsOnInsertion {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: common_grpc_expr::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to convert into vectors"))]
|
||||
IntoVectors {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: datatypes::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to deserialize partition in meta to partition def"))]
|
||||
DeserializePartition {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: partition::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to describe schema for given statement"))]
|
||||
DescribeStatement {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
@@ -249,7 +254,7 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Unrecognized table option"))]
|
||||
UnrecognizedTableOption {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: table::error::Error,
|
||||
},
|
||||
|
||||
@@ -262,26 +267,27 @@ pub enum Error {
|
||||
#[snafu(display("Failed to build regex"))]
|
||||
BuildRegex {
|
||||
location: Location,
|
||||
source: regex::Error,
|
||||
#[snafu(source)]
|
||||
error: regex::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to copy table: {}", table_name))]
|
||||
CopyTable {
|
||||
table_name: String,
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: table::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to insert value into table: {}", table_name))]
|
||||
Insert {
|
||||
table_name: String,
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: table::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse data source url"))]
|
||||
ParseUrl {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: common_datasource::error::Error,
|
||||
},
|
||||
|
||||
@@ -290,39 +296,40 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to parse file format"))]
|
||||
ParseFileFormat {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: common_datasource::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to build data source backend"))]
|
||||
BuildBackend {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: common_datasource::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to list objects"))]
|
||||
ListObjects {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: common_datasource::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to infer schema from path: {}", path))]
|
||||
InferSchema {
|
||||
path: String,
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: common_datasource::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to build csv config"))]
|
||||
BuildCsvConfig {
|
||||
source: common_datasource::file_format::csv::CsvConfigBuilderError,
|
||||
#[snafu(source)]
|
||||
error: common_datasource::file_format::csv::CsvConfigBuilderError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to write stream to path: {}", path))]
|
||||
WriteStreamToFile {
|
||||
path: String,
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: common_datasource::error::Error,
|
||||
},
|
||||
|
||||
@@ -330,18 +337,21 @@ pub enum Error {
|
||||
ReadObject {
|
||||
path: String,
|
||||
location: Location,
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to read record batch"))]
|
||||
ReadDfRecordBatch {
|
||||
source: datafusion::error::DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: datafusion::error::DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to read parquet file"))]
|
||||
ReadParquet {
|
||||
source: parquet::errors::ParquetError,
|
||||
#[snafu(source)]
|
||||
error: parquet::errors::ParquetError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -354,18 +364,20 @@ pub enum Error {
|
||||
#[snafu(display("Failed to build parquet record batch stream"))]
|
||||
BuildParquetRecordBatchStream {
|
||||
location: Location,
|
||||
source: parquet::errors::ParquetError,
|
||||
#[snafu(source)]
|
||||
error: parquet::errors::ParquetError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to build file stream"))]
|
||||
BuildFileStream {
|
||||
location: Location,
|
||||
source: datafusion::error::DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: datafusion::error::DataFusionError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to write parquet file"))]
|
||||
WriteParquet {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: storage::error::Error,
|
||||
},
|
||||
|
||||
@@ -384,19 +396,21 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to project schema"))]
|
||||
ProjectSchema {
|
||||
source: ArrowError,
|
||||
#[snafu(source)]
|
||||
error: ArrowError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to encode object into json"))]
|
||||
EncodeJson {
|
||||
source: serde_json::error::Error,
|
||||
#[snafu(source)]
|
||||
error: serde_json::error::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to prepare immutable table"))]
|
||||
PrepareImmutableTable {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
@@ -457,19 +471,19 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to prepare file table"))]
|
||||
PrepareFileTable {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to infer file table schema"))]
|
||||
InferFileTableSchema {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("The schema of the file table is incompatible with the table schema"))]
|
||||
SchemaIncompatible {
|
||||
#[snafu(backtrace)]
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
}
|
||||
@@ -502,7 +516,7 @@ impl ErrorExt for Error {
|
||||
|
||||
Error::TableMetadataManager { source, .. } => source.status_code(),
|
||||
|
||||
Error::ConvertSqlValue { source, .. } | Error::ParseSql { source } => {
|
||||
Error::ConvertSqlValue { source, .. } | Error::ParseSql { source, .. } => {
|
||||
source.status_code()
|
||||
}
|
||||
|
||||
@@ -512,18 +526,18 @@ impl ErrorExt for Error {
|
||||
source.status_code()
|
||||
}
|
||||
|
||||
Error::Table { source }
|
||||
Error::Table { source, .. }
|
||||
| Error::CopyTable { source, .. }
|
||||
| Error::Insert { source, .. } => source.status_code(),
|
||||
|
||||
Error::ConvertColumnDefaultConstraint { source, .. }
|
||||
| Error::CreateTableInfo { source }
|
||||
| Error::IntoVectors { source } => source.status_code(),
|
||||
| Error::CreateTableInfo { source, .. }
|
||||
| Error::IntoVectors { source, .. } => source.status_code(),
|
||||
|
||||
Error::RequestInserts { source } => source.status_code(),
|
||||
Error::RequestDeletes { source } => source.status_code(),
|
||||
Error::RequestInserts { source, .. } => source.status_code(),
|
||||
Error::RequestDeletes { source, .. } => source.status_code(),
|
||||
|
||||
Error::ColumnDataType { source } | Error::InvalidColumnDef { source, .. } => {
|
||||
Error::ColumnDataType { source, .. } | Error::InvalidColumnDef { source, .. } => {
|
||||
source.status_code()
|
||||
}
|
||||
|
||||
@@ -546,18 +560,18 @@ impl ErrorExt for Error {
|
||||
|
||||
Error::Catalog { source, .. } => source.status_code(),
|
||||
|
||||
Error::BuildCreateExprOnInsertion { source }
|
||||
| Error::FindNewColumnsOnInsertion { source } => source.status_code(),
|
||||
Error::BuildCreateExprOnInsertion { source, .. }
|
||||
| Error::FindNewColumnsOnInsertion { source, .. } => source.status_code(),
|
||||
|
||||
Error::ExecuteStatement { source, .. }
|
||||
| Error::PlanStatement { source }
|
||||
| Error::ParseQuery { source }
|
||||
| Error::ExecLogicalPlan { source }
|
||||
| Error::DescribeStatement { source } => source.status_code(),
|
||||
| Error::PlanStatement { source, .. }
|
||||
| Error::ParseQuery { source, .. }
|
||||
| Error::ExecLogicalPlan { source, .. }
|
||||
| Error::DescribeStatement { source, .. } => source.status_code(),
|
||||
|
||||
Error::AlterExprToRequest { source, .. } => source.status_code(),
|
||||
|
||||
Error::External { source } => source.status_code(),
|
||||
Error::External { source, .. } => source.status_code(),
|
||||
Error::DeserializePartition { source, .. }
|
||||
| Error::FindTablePartitionRule { source, .. }
|
||||
| Error::SplitInsert { source, .. }
|
||||
@@ -570,9 +584,9 @@ impl ErrorExt for Error {
|
||||
StatusCode::StorageUnavailable
|
||||
}
|
||||
|
||||
Error::ListObjects { source }
|
||||
| Error::ParseUrl { source }
|
||||
| Error::BuildBackend { source } => source.status_code(),
|
||||
Error::ListObjects { source, .. }
|
||||
| Error::ParseUrl { source, .. }
|
||||
| Error::BuildBackend { source, .. } => source.status_code(),
|
||||
|
||||
Error::WriteParquet { source, .. } => source.status_code(),
|
||||
Error::ExecuteDdl { source, .. } => source.status_code(),
|
||||
|
||||
@@ -11,6 +11,7 @@ api = { workspace = true }
|
||||
async-trait = "0.1"
|
||||
common-catalog = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-meta = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
common-telemetry = { workspace = true }
|
||||
|
||||
@@ -16,14 +16,16 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use common_query::prelude::Expr;
|
||||
use datafusion_common::ScalarValue;
|
||||
use snafu::{Location, Snafu};
|
||||
use store_api::storage::{RegionId, RegionNumber};
|
||||
use table::metadata::TableId;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Table route manager error"))]
|
||||
TableRouteManager {
|
||||
@@ -66,13 +68,15 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to serialize value to json"))]
|
||||
SerializeJson {
|
||||
source: serde_json::Error,
|
||||
#[snafu(source)]
|
||||
error: serde_json::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to deserialize value from json"))]
|
||||
DeserializeJson {
|
||||
source: serde_json::Error,
|
||||
#[snafu(source)]
|
||||
error: serde_json::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -16,12 +16,14 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use datafusion::error::DataFusionError;
|
||||
use promql_parser::parser::{Expr as PromExpr, TokenType};
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Unsupported expr type: {}", name))]
|
||||
UnsupportedExpr { name: String, location: Location },
|
||||
@@ -34,7 +36,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Internal error during building DataFusion plan"))]
|
||||
DataFusionPlanning {
|
||||
source: datafusion::error::DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: datafusion::error::DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -73,7 +76,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to deserialize"))]
|
||||
Deserialize {
|
||||
source: prost::DecodeError,
|
||||
#[snafu(source)]
|
||||
error: prost::DecodeError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ common-catalog.workspace = true
|
||||
common-datasource.workspace = true
|
||||
common-error.workspace = true
|
||||
common-function.workspace = true
|
||||
common-macro.workspace = true
|
||||
common-meta.workspace = true
|
||||
common-query.workspace = true
|
||||
common-recordbatch.workspace = true
|
||||
|
||||
@@ -16,17 +16,20 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use datafusion::error::DataFusionError;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
/// Inner error of datafusion based query engine.
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum InnerError {
|
||||
#[snafu(display("msg: {}", msg))]
|
||||
Datafusion {
|
||||
msg: &'static str,
|
||||
source: DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
+13
-6
@@ -17,14 +17,16 @@ use std::time::Duration;
|
||||
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use common_meta::table_name::TableName;
|
||||
use datafusion::error::DataFusionError;
|
||||
use datatypes::prelude::ConcreteDataType;
|
||||
use datatypes::value::Value;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Unsupported expr type: {}", name))]
|
||||
UnsupportedExpr { name: String, location: Location },
|
||||
@@ -106,20 +108,23 @@ pub enum Error {
|
||||
#[snafu(display("Failed to parse timestamp `{}`", raw))]
|
||||
ParseTimestamp {
|
||||
raw: String,
|
||||
source: chrono::ParseError,
|
||||
#[snafu(source)]
|
||||
error: chrono::ParseError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse float number `{}`", raw))]
|
||||
ParseFloat {
|
||||
raw: String,
|
||||
source: std::num::ParseFloatError,
|
||||
#[snafu(source)]
|
||||
error: std::num::ParseFloatError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("DataFusion error"))]
|
||||
DataFusion {
|
||||
source: DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -138,7 +143,8 @@ pub enum Error {
|
||||
#[snafu(display("Cannot plan SQL: {}", sql))]
|
||||
PlanSql {
|
||||
sql: String,
|
||||
source: DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -194,7 +200,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to regex"))]
|
||||
BuildRegex {
|
||||
location: Location,
|
||||
source: regex::Error,
|
||||
#[snafu(source)]
|
||||
error: regex::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to build data source backend"))]
|
||||
|
||||
@@ -32,6 +32,7 @@ catalog = { workspace = true }
|
||||
common-catalog = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-function = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
common-recordbatch = { workspace = true }
|
||||
common-runtime = { workspace = true }
|
||||
|
||||
@@ -16,10 +16,12 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to find column in scripts table, name: {}", name))]
|
||||
FindColumnInScriptsTable { name: String, location: Location },
|
||||
@@ -62,7 +64,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to build DataFusion logical plan"))]
|
||||
BuildDfLogicalPlan {
|
||||
source: datafusion_common::DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: datafusion_common::DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use console::{style, Style};
|
||||
use datafusion::error::DataFusionError;
|
||||
use datatypes::arrow::error::ArrowError;
|
||||
@@ -31,8 +32,9 @@ pub(crate) fn ret_other_error_with(reason: String) -> OtherSnafu<String> {
|
||||
OtherSnafu { reason }
|
||||
}
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub(crate)))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Datatype error"))]
|
||||
TypeCast {
|
||||
@@ -49,13 +51,15 @@ pub enum Error {
|
||||
#[snafu(display("Failed to parse script"))]
|
||||
PyParse {
|
||||
location: SnafuLocation,
|
||||
source: ParseError,
|
||||
#[snafu(source)]
|
||||
error: ParseError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to compile script"))]
|
||||
PyCompile {
|
||||
location: SnafuLocation,
|
||||
source: CodegenError,
|
||||
#[snafu(source)]
|
||||
error: CodegenError,
|
||||
},
|
||||
|
||||
/// rustpython problem, using python virtual machines' backtrace instead
|
||||
@@ -68,13 +72,15 @@ pub enum Error {
|
||||
#[snafu(display("Arrow error"))]
|
||||
Arrow {
|
||||
location: SnafuLocation,
|
||||
source: ArrowError,
|
||||
#[snafu(source)]
|
||||
error: ArrowError,
|
||||
},
|
||||
|
||||
#[snafu(display("DataFusion error"))]
|
||||
DataFusion {
|
||||
location: SnafuLocation,
|
||||
source: DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: DataFusionError,
|
||||
},
|
||||
|
||||
/// errors in coprocessors' parse check for types and etc.
|
||||
@@ -116,7 +122,10 @@ pub enum Error {
|
||||
source: common_recordbatch::error::Error,
|
||||
},
|
||||
#[snafu(display("Failed to create tokio task"))]
|
||||
TokioJoin { source: tokio::task::JoinError },
|
||||
TokioJoin {
|
||||
#[snafu(source)]
|
||||
error: tokio::task::JoinError,
|
||||
},
|
||||
}
|
||||
|
||||
impl ErrorExt for Error {
|
||||
@@ -210,8 +219,8 @@ pub fn get_error_reason_loc(err: &Error) -> (String, Option<Location>) {
|
||||
Error::CoprParse { reason, loc, .. } => (reason.clone(), *loc),
|
||||
Error::Other { reason, .. } => (reason.clone(), None),
|
||||
Error::PyRuntime { msg, .. } => (msg.clone(), None),
|
||||
Error::PyParse { source, .. } => (source.error.to_string(), Some(source.location)),
|
||||
Error::PyCompile { source, .. } => (source.error.to_string(), Some(source.location)),
|
||||
Error::PyParse { error, .. } => (error.error.to_string(), Some(error.location)),
|
||||
Error::PyCompile { error, .. } => (error.error.to_string(), Some(error.location)),
|
||||
_ => (format!("Unknown error: {err:?}"), None),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,16 +253,12 @@ def calc_rvs(open_time, close):
|
||||
)
|
||||
.unwrap();
|
||||
let ret = exec_coprocessor(python_source, &Some(rb));
|
||||
if let Err(Error::PyParse {
|
||||
location: _,
|
||||
source,
|
||||
}) = ret
|
||||
{
|
||||
if let Err(Error::PyParse { location: _, error }) = ret {
|
||||
let res = visualize_loc(
|
||||
python_source,
|
||||
&source.location,
|
||||
&error.location,
|
||||
"unknown tokens",
|
||||
source.error.to_string().as_str(),
|
||||
error.error.to_string().as_str(),
|
||||
0,
|
||||
"copr.py",
|
||||
);
|
||||
@@ -303,16 +299,12 @@ def a(cpu, mem):
|
||||
)
|
||||
.unwrap();
|
||||
let ret = exec_coprocessor(python_source, &Some(rb));
|
||||
if let Err(Error::PyParse {
|
||||
location: _,
|
||||
source,
|
||||
}) = ret
|
||||
{
|
||||
if let Err(Error::PyParse { location: _, error }) = ret {
|
||||
let res = visualize_loc(
|
||||
python_source,
|
||||
&source.location,
|
||||
&error.location,
|
||||
"unknown tokens",
|
||||
source.error.to_string().as_str(),
|
||||
error.error.to_string().as_str(),
|
||||
0,
|
||||
"copr.py",
|
||||
);
|
||||
|
||||
@@ -27,6 +27,7 @@ common-catalog = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-grpc = { workspace = true }
|
||||
common-grpc-expr = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-mem-prof = { workspace = true, optional = true }
|
||||
common-meta = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
|
||||
+57
-26
@@ -22,6 +22,7 @@ use base64::DecodeError;
|
||||
use catalog;
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use common_telemetry::logging;
|
||||
use datatypes::prelude::ConcreteDataType;
|
||||
use query::parser::PromQuery;
|
||||
@@ -29,19 +30,24 @@ use serde_json::json;
|
||||
use snafu::{ErrorCompat, Location, Snafu};
|
||||
use tonic::Code;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Internal error: {}", err_msg))]
|
||||
Internal { err_msg: String },
|
||||
|
||||
#[snafu(display("Internal IO error"))]
|
||||
InternalIo { source: std::io::Error },
|
||||
InternalIo {
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Tokio IO error: {}", err_msg))]
|
||||
TokioIo {
|
||||
err_msg: String,
|
||||
source: std::io::Error,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to collect recordbatch"))]
|
||||
@@ -51,10 +57,16 @@ pub enum Error {
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to start HTTP server"))]
|
||||
StartHttp { source: hyper::Error },
|
||||
StartHttp {
|
||||
#[snafu(source)]
|
||||
error: hyper::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to start gRPC server"))]
|
||||
StartGrpc { source: tonic::transport::Error },
|
||||
StartGrpc {
|
||||
#[snafu(source)]
|
||||
error: tonic::transport::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("{} server is already started", server))]
|
||||
AlreadyStarted { server: String, location: Location },
|
||||
@@ -62,7 +74,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to bind address {}", addr))]
|
||||
TcpBind {
|
||||
addr: SocketAddr,
|
||||
source: std::io::Error,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to execute query, query: {}", query))]
|
||||
@@ -125,7 +138,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to parse InfluxDB line protocol"))]
|
||||
InfluxdbLineProtocol {
|
||||
location: Location,
|
||||
source: influxdb_line_protocol::Error,
|
||||
#[snafu(source)]
|
||||
error: influxdb_line_protocol::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to write InfluxDB line protocol"))]
|
||||
@@ -153,36 +167,44 @@ pub enum Error {
|
||||
ConnResetByPeer { location: Location },
|
||||
|
||||
#[snafu(display("Hyper error"))]
|
||||
Hyper { source: hyper::Error },
|
||||
Hyper {
|
||||
#[snafu(source)]
|
||||
error: hyper::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Invalid OpenTSDB line"))]
|
||||
InvalidOpentsdbLine {
|
||||
source: FromUtf8Error,
|
||||
#[snafu(source)]
|
||||
error: FromUtf8Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Invalid OpenTSDB Json request"))]
|
||||
InvalidOpentsdbJsonRequest {
|
||||
source: serde_json::error::Error,
|
||||
#[snafu(source)]
|
||||
error: serde_json::error::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to decode prometheus remote request"))]
|
||||
DecodePromRemoteRequest {
|
||||
location: Location,
|
||||
source: prost::DecodeError,
|
||||
#[snafu(source)]
|
||||
error: prost::DecodeError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to decode OTLP request"))]
|
||||
DecodeOtlpRequest {
|
||||
location: Location,
|
||||
source: prost::DecodeError,
|
||||
#[snafu(source)]
|
||||
error: prost::DecodeError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to decompress prometheus remote request"))]
|
||||
DecompressPromRemoteRequest {
|
||||
location: Location,
|
||||
source: snap::Error,
|
||||
#[snafu(source)]
|
||||
error: snap::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Invalid prometheus remote request, msg: {}", msg))]
|
||||
@@ -193,7 +215,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Invalid Flight ticket"))]
|
||||
InvalidFlightTicket {
|
||||
source: api::DecodeError,
|
||||
#[snafu(source)]
|
||||
error: api::DecodeError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -214,7 +237,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Invalid visibility ASCII chars"))]
|
||||
InvisibleASCII {
|
||||
source: hyper::header::ToStrError,
|
||||
#[snafu(source)]
|
||||
error: hyper::header::ToStrError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -226,13 +250,15 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Invalid base64 value"))]
|
||||
InvalidBase64Value {
|
||||
source: DecodeError,
|
||||
#[snafu(source)]
|
||||
error: DecodeError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Invalid utf-8 value"))]
|
||||
InvalidUtf8Value {
|
||||
source: FromUtf8Error,
|
||||
#[snafu(source)]
|
||||
error: FromUtf8Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -246,7 +272,8 @@ pub enum Error {
|
||||
#[snafu(display("Failed to dump profile data"))]
|
||||
DumpProfileData {
|
||||
location: Location,
|
||||
source: common_mem_prof::error::Error,
|
||||
#[snafu(source)]
|
||||
error: common_mem_prof::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Invalid prepare statement: {}", err_msg))]
|
||||
@@ -257,13 +284,15 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to build gRPC reflection service"))]
|
||||
GrpcReflectionService {
|
||||
source: tonic_reflection::server::Error,
|
||||
#[snafu(source)]
|
||||
error: tonic_reflection::server::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to build HTTP response"))]
|
||||
BuildHttpResponse {
|
||||
source: http::Error,
|
||||
#[snafu(source)]
|
||||
error: http::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -293,7 +322,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to join task"))]
|
||||
JoinTask {
|
||||
source: tokio::task::JoinError,
|
||||
#[snafu(source)]
|
||||
error: tokio::task::JoinError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -306,7 +336,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("DataFrame operation error"))]
|
||||
DataFrame {
|
||||
source: datafusion::error::DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: datafusion::error::DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -418,10 +449,10 @@ impl ErrorExt for Error {
|
||||
|
||||
UnexpectedResult { .. } => StatusCode::Unexpected,
|
||||
|
||||
JoinTask { source, .. } => {
|
||||
if source.is_cancelled() {
|
||||
JoinTask { error, .. } => {
|
||||
if error.is_cancelled() {
|
||||
StatusCode::Cancelled
|
||||
} else if source.is_panic() {
|
||||
} else if error.is_panic() {
|
||||
StatusCode::Unexpected
|
||||
} else {
|
||||
StatusCode::Unknown
|
||||
@@ -511,7 +542,7 @@ define_into_tonic_status!(Error);
|
||||
|
||||
impl From<std::io::Error> for Error {
|
||||
fn from(e: std::io::Error) -> Self {
|
||||
Error::InternalIo { source: e }
|
||||
Error::InternalIo { error: e }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,14 +16,17 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to update jemalloc metrics"))]
|
||||
UpdateJemallocMetrics {
|
||||
source: tikv_jemalloc_ctl::Error,
|
||||
#[snafu(source)]
|
||||
error: tikv_jemalloc_ctl::Error,
|
||||
location: Location,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ api = { workspace = true }
|
||||
common-base = { workspace = true }
|
||||
common-catalog = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
common-time = { workspace = true }
|
||||
datafusion-sql.workspace = true
|
||||
|
||||
+10
-3
@@ -16,6 +16,7 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use common_time::timestamp::TimeUnit;
|
||||
use common_time::Timestamp;
|
||||
use datatypes::prelude::{ConcreteDataType, Value};
|
||||
@@ -29,8 +30,9 @@ pub type Result<T> = std::result::Result<T, Error>;
|
||||
/// SQL parser errors.
|
||||
// Now the error in parser does not contains backtrace to avoid generating backtrace
|
||||
// every time the parser parses an invalid SQL.
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("SQL statement is not supported: {}, keyword: {}", sql, keyword))]
|
||||
Unsupported { sql: String, keyword: String },
|
||||
@@ -45,7 +47,8 @@ pub enum Error {
|
||||
sql: String,
|
||||
expected: String,
|
||||
actual: String,
|
||||
source: ParserError,
|
||||
#[snafu(source)]
|
||||
error: ParserError,
|
||||
},
|
||||
|
||||
#[snafu(display(
|
||||
@@ -57,7 +60,11 @@ pub enum Error {
|
||||
|
||||
// Syntax error from sql parser.
|
||||
#[snafu(display("Syntax error, sql: {}", sql))]
|
||||
Syntax { sql: String, source: ParserError },
|
||||
Syntax {
|
||||
sql: String,
|
||||
#[snafu(source)]
|
||||
error: ParserError,
|
||||
},
|
||||
|
||||
#[snafu(display("Missing time index constraint"))]
|
||||
MissingTimeIndex {},
|
||||
|
||||
@@ -602,7 +602,7 @@ mod tests {
|
||||
assert!(v.is_err());
|
||||
assert!(
|
||||
format!("{v:?}").contains(
|
||||
"column_name: \"a\", expect: Float64(Float64Type), actual: Boolean(BooleanType)"
|
||||
"Column a expect type: Float64(Float64Type), actual: Boolean(BooleanType))"
|
||||
),
|
||||
"v is {v:?}",
|
||||
);
|
||||
|
||||
@@ -16,6 +16,7 @@ bytes = "1.1"
|
||||
common-base = { workspace = true }
|
||||
common-datasource = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
common-recordbatch = { workspace = true }
|
||||
common-runtime = { workspace = true }
|
||||
|
||||
+55
-27
@@ -19,6 +19,7 @@ use std::str::Utf8Error;
|
||||
use common_datasource::compression::CompressionType;
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use common_runtime::error::Error as RuntimeError;
|
||||
use datatypes::arrow::error::ArrowError;
|
||||
use datatypes::prelude::ConcreteDataType;
|
||||
@@ -33,8 +34,9 @@ use tokio::task::JoinError;
|
||||
use crate::metadata::Error as MetadataError;
|
||||
use crate::write_batch;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Invalid region descriptor, region: {}", region))]
|
||||
InvalidRegionDesc {
|
||||
@@ -48,7 +50,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to write parquet file"))]
|
||||
WriteParquet {
|
||||
source: parquet::errors::ParquetError,
|
||||
#[snafu(source)]
|
||||
error: parquet::errors::ParquetError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -61,67 +64,77 @@ pub enum Error {
|
||||
#[snafu(display("Failed to create RecordBatch from vectors"))]
|
||||
NewRecordBatch {
|
||||
location: Location,
|
||||
source: ArrowError,
|
||||
#[snafu(source)]
|
||||
error: ArrowError,
|
||||
},
|
||||
|
||||
#[snafu(display("Fail to read object from path: {}", path))]
|
||||
ReadObject {
|
||||
path: String,
|
||||
location: Location,
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Fail to write object into path: {}", path))]
|
||||
WriteObject {
|
||||
path: String,
|
||||
location: Location,
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Fail to delete object from path: {}", path))]
|
||||
DeleteObject {
|
||||
path: String,
|
||||
location: Location,
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Fail to compress object by {}, path: {}", compress_type, path))]
|
||||
CompressObject {
|
||||
compress_type: CompressionType,
|
||||
path: String,
|
||||
source: std::io::Error,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Fail to decompress object by {}, path: {}", compress_type, path))]
|
||||
DecompressObject {
|
||||
compress_type: CompressionType,
|
||||
path: String,
|
||||
source: std::io::Error,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Fail to list objects in path: {}", path))]
|
||||
ListObjects {
|
||||
path: String,
|
||||
location: Location,
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Fail to create str from bytes"))]
|
||||
Utf8 {
|
||||
location: Location,
|
||||
source: Utf8Error,
|
||||
#[snafu(source)]
|
||||
error: Utf8Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Fail to encode object into json "))]
|
||||
EncodeJson {
|
||||
location: Location,
|
||||
source: JsonError,
|
||||
#[snafu(source)]
|
||||
error: JsonError,
|
||||
},
|
||||
|
||||
#[snafu(display("Fail to decode object from json "))]
|
||||
DecodeJson {
|
||||
location: Location,
|
||||
source: JsonError,
|
||||
#[snafu(source)]
|
||||
error: JsonError,
|
||||
},
|
||||
|
||||
#[snafu(display("Invalid scan index, start: {}, end: {}", start, end))]
|
||||
@@ -141,19 +154,22 @@ pub enum Error {
|
||||
#[snafu(display("Failed to encode WAL header"))]
|
||||
EncodeWalHeader {
|
||||
location: Location,
|
||||
source: std::io::Error,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to decode WAL header"))]
|
||||
DecodeWalHeader {
|
||||
location: Location,
|
||||
source: std::io::Error,
|
||||
#[snafu(source)]
|
||||
error: std::io::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to wait flushing, region_id: {}", region_id))]
|
||||
WaitFlush {
|
||||
region_id: RegionId,
|
||||
source: tokio::sync::oneshot::error::RecvError,
|
||||
#[snafu(source)]
|
||||
error: tokio::sync::oneshot::error::RecvError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -183,12 +199,16 @@ pub enum Error {
|
||||
DecodeMetaActionList { msg: String, location: Location },
|
||||
|
||||
#[snafu(display("Failed to read line, err"))]
|
||||
Readline { source: IoError },
|
||||
Readline {
|
||||
#[snafu(source)]
|
||||
error: IoError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to read Parquet file: {}", file))]
|
||||
ReadParquet {
|
||||
file: String,
|
||||
source: parquet::errors::ParquetError,
|
||||
#[snafu(source)]
|
||||
error: parquet::errors::ParquetError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -385,13 +405,15 @@ pub enum Error {
|
||||
#[snafu(display("Failed to decode arrow data"))]
|
||||
DecodeArrow {
|
||||
location: Location,
|
||||
source: ArrowError,
|
||||
#[snafu(source)]
|
||||
error: ArrowError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to encode arrow data"))]
|
||||
EncodeArrow {
|
||||
location: Location,
|
||||
source: ArrowError,
|
||||
#[snafu(source)]
|
||||
error: ArrowError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse schema"))]
|
||||
@@ -426,13 +448,15 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to stop scheduler"))]
|
||||
StopScheduler {
|
||||
source: JoinError,
|
||||
#[snafu(source)]
|
||||
error: JoinError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to delete SST file"))]
|
||||
DeleteSst {
|
||||
source: object_store::Error,
|
||||
#[snafu(source)]
|
||||
error: object_store::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -448,7 +472,8 @@ pub enum Error {
|
||||
#[snafu(display("The compaction task is cancelled, region_id: {}", region_id))]
|
||||
CompactTaskCancel {
|
||||
region_id: RegionId,
|
||||
source: tokio::sync::oneshot::error::RecvError,
|
||||
#[snafu(source)]
|
||||
error: tokio::sync::oneshot::error::RecvError,
|
||||
},
|
||||
|
||||
#[snafu(display(
|
||||
@@ -476,13 +501,15 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to convert columns to rows"))]
|
||||
ConvertColumnsToRows {
|
||||
source: ArrowError,
|
||||
#[snafu(source)]
|
||||
error: ArrowError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to sort arrays"))]
|
||||
SortArrays {
|
||||
source: ArrowError,
|
||||
#[snafu(source)]
|
||||
error: ArrowError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -494,7 +521,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to join spawned tasks"))]
|
||||
JoinError {
|
||||
source: JoinError,
|
||||
#[snafu(source)]
|
||||
error: JoinError,
|
||||
location: Location,
|
||||
},
|
||||
}
|
||||
@@ -505,8 +533,8 @@ impl Error {
|
||||
/// Returns true if the error is the object path to delete
|
||||
/// doesn't exist.
|
||||
pub(crate) fn is_object_to_delete_not_found(&self) -> bool {
|
||||
if let Error::DeleteObject { source, .. } = self {
|
||||
source.kind() == ErrorKind::NotFound
|
||||
if let Error::DeleteObject { error, .. } = self {
|
||||
error.kind() == ErrorKind::NotFound
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ use std::sync::Arc;
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use datatypes::data_type::ConcreteDataType;
|
||||
use datatypes::schema::{ColumnSchema, Metadata, COMMENT_KEY};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -35,8 +36,9 @@ use crate::manifest::action::{RawColumnFamiliesMetadata, RawColumnsMetadata, Raw
|
||||
use crate::schema::{RegionSchema, RegionSchemaRef};
|
||||
|
||||
/// Error for handling metadata.
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub(crate)))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Column name {} already exists", name))]
|
||||
ColNameExists { name: String, location: Location },
|
||||
@@ -95,7 +97,8 @@ pub enum Error {
|
||||
ParseMetaInt {
|
||||
// Store key and value in one string to reduce the enum size.
|
||||
key_value: String,
|
||||
source: std::num::ParseIntError,
|
||||
#[snafu(source)]
|
||||
error: std::num::ParseIntError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -104,7 +107,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to build column descriptor"))]
|
||||
BuildColumnDescriptor {
|
||||
source: ColumnDescriptorBuilderError,
|
||||
#[snafu(source)]
|
||||
error: ColumnDescriptorBuilderError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ async-trait.workspace = true
|
||||
bytes = "1.1"
|
||||
common-base = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
common-recordbatch = { workspace = true }
|
||||
common-time = { workspace = true }
|
||||
|
||||
@@ -14,12 +14,14 @@
|
||||
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use snafu::{Location, Snafu};
|
||||
|
||||
use crate::storage::ColumnDescriptorBuilderError;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Invalid raw region request: {err}"))]
|
||||
InvalidRawRegionRequest { err: String, location: Location },
|
||||
@@ -33,7 +35,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to build column descriptor: "))]
|
||||
BuildColumnDescriptor {
|
||||
source: ColumnDescriptorBuilderError,
|
||||
#[snafu(source)]
|
||||
error: ColumnDescriptorBuilderError,
|
||||
location: Location,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ mod tests {
|
||||
use std::any::Any;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use common_error::ext::StackError;
|
||||
use futures::StreamExt;
|
||||
use snafu::Snafu;
|
||||
|
||||
@@ -63,6 +64,14 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
impl StackError for Error {
|
||||
fn debug_fmt(&self, _: usize, _: &mut Vec<String>) {}
|
||||
|
||||
fn next(&self) -> Option<&dyn StackError> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl Entry for SimpleEntry {
|
||||
type Error = Error;
|
||||
type Namespace = Namespace;
|
||||
|
||||
@@ -25,6 +25,7 @@ use api::v1::region::RegionColumnDef;
|
||||
use api::v1::SemanticType;
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use datatypes::arrow::datatypes::FieldRef;
|
||||
use datatypes::schema::{ColumnDefaultConstraint, ColumnSchema, Schema, SchemaRef};
|
||||
use serde::de::Error;
|
||||
@@ -558,8 +559,9 @@ impl SkippedFields {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum MetadataError {
|
||||
#[snafu(display("Invalid schema"))]
|
||||
InvalidSchema {
|
||||
@@ -573,7 +575,8 @@ pub enum MetadataError {
|
||||
#[snafu(display("Failed to ser/de json object"))]
|
||||
SerdeJson {
|
||||
location: Location,
|
||||
source: serde_json::Error,
|
||||
#[snafu(source)]
|
||||
error: serde_json::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to convert struct from datatypes"))]
|
||||
|
||||
@@ -15,6 +15,7 @@ common-base = { workspace = true }
|
||||
common-catalog = { workspace = true }
|
||||
common-datasource = { workspace = true }
|
||||
common-error = { workspace = true }
|
||||
common-macro = { workspace = true }
|
||||
common-procedure = { workspace = true }
|
||||
common-query = { workspace = true }
|
||||
common-recordbatch = { workspace = true }
|
||||
|
||||
@@ -16,6 +16,7 @@ use std::any::Any;
|
||||
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use datafusion::error::DataFusionError;
|
||||
use datatypes::arrow::error::ArrowError;
|
||||
use snafu::{Location, Snafu};
|
||||
@@ -25,12 +26,14 @@ use crate::metadata::TableId;
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
/// Default error implementation of table.
|
||||
#[derive(Debug, Snafu)]
|
||||
#[derive(Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Datafusion error"))]
|
||||
Datafusion {
|
||||
source: DataFusionError,
|
||||
#[snafu(source)]
|
||||
error: DataFusionError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -48,7 +51,8 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Table projection error"))]
|
||||
TableProjection {
|
||||
source: ArrowError,
|
||||
#[snafu(source)]
|
||||
error: ArrowError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
@@ -99,7 +103,8 @@ pub enum Error {
|
||||
column_name,
|
||||
))]
|
||||
BuildColumnDescriptor {
|
||||
source: store_api::storage::ColumnDescriptorBuilderError,
|
||||
#[snafu(source)]
|
||||
error: store_api::storage::ColumnDescriptorBuilderError,
|
||||
table_name: String,
|
||||
column_name: String,
|
||||
location: Location,
|
||||
|
||||
Reference in New Issue
Block a user