Skip to content

Commit

Permalink
feat: stack trace style debug print for error (#2489)
Browse files Browse the repository at this point in the history
* impl macro stack_trace_debug

Signed-off-by: Ruihang Xia <[email protected]>

* manually mark external error

Signed-off-by: Ruihang Xia <[email protected]>

* ignore warnings

Signed-off-by: Ruihang Xia <[email protected]>

* fix clippy warnings

Signed-off-by: Ruihang Xia <[email protected]>

* use debug print

Signed-off-by: Ruihang Xia <[email protected]>

* simplify the error and warn macro

Signed-off-by: Ruihang Xia <[email protected]>

* fix ut

Signed-off-by: Ruihang Xia <[email protected]>

* add docs

Signed-off-by: Ruihang Xia <[email protected]>

* replace snafu backtrace with location

Signed-off-by: Ruihang Xia <[email protected]>

---------

Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia authored Sep 26, 2023
1 parent 7fc9604 commit 515ce82
Show file tree
Hide file tree
Showing 94 changed files with 1,209 additions and 504 deletions.
35 changes: 35 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions src/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/api/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
1 change: 1 addition & 0 deletions src/auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
7 changes: 5 additions & 2 deletions src/auth/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -30,7 +32,8 @@ pub enum Error {

#[snafu(display("IO error"))]
Io {
source: std::io::Error,
#[snafu(source)]
error: std::io::Error,
location: Location,
},

Expand Down
1 change: 1 addition & 0 deletions src/catalog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
15 changes: 11 additions & 4 deletions src/catalog/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
},

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -213,7 +219,8 @@ pub enum Error {
#[snafu(display("msg: {}", msg))]
Datafusion {
msg: String,
source: DataFusionError,
#[snafu(source)]
error: DataFusionError,
location: Location,
},

Expand Down
Loading

0 comments on commit 515ce82

Please sign in to comment.