Skip to content

Commit

Permalink
refactor: remove source and location in snafu display (#2428)
Browse files Browse the repository at this point in the history
* refactor: remove source pt 1

* refactor: remove source pt 2

* refactor: remove source pt 3

* refactor: remove location pt 1

* refactor: remove location pt 2

* chore: remove rustc files

* chore: fix error case

* chore: fix test

* chore: fix test

* chore: fix cr issue

Co-authored-by: fys <[email protected]>

---------

Co-authored-by: fys <[email protected]>
  • Loading branch information
shuiyisong and fengys1996 authored Sep 21, 2023
1 parent 9863e50 commit 20f4f79
Show file tree
Hide file tree
Showing 51 changed files with 680 additions and 1,031 deletions.
12 changes: 2 additions & 10 deletions src/api/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,14 @@ pub enum Error {
location: Location,
},

#[snafu(display(
"Failed to convert column default constraint, column: {}, source: {}",
column,
source
))]
#[snafu(display("Failed to convert column default constraint, column: {}", column))]
ConvertColumnDefaultConstraint {
column: String,
location: Location,
source: datatypes::error::Error,
},

#[snafu(display(
"Invalid column default constraint, column: {}, source: {}",
column,
source
))]
#[snafu(display("Invalid column default constraint, column: {}", column))]
InvalidColumnDefaultConstraint {
column: String,
location: Location,
Expand Down
4 changes: 2 additions & 2 deletions src/auth/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ pub enum Error {
#[snafu(display("Internal state error: {}", msg))]
InternalState { msg: String },

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

#[snafu(display("Auth failed, source: {}", source))]
#[snafu(display("Auth failed"))]
AuthBackend {
location: Location,
source: BoxedError,
Expand Down
57 changes: 22 additions & 35 deletions src/catalog/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,37 @@ use tokio::task::JoinError;
#[derive(Debug, Snafu)]
#[snafu(visibility(pub))]
pub enum Error {
#[snafu(display("Failed to list catalogs, source: {}", source))]
#[snafu(display("Failed to list catalogs"))]
ListCatalogs {
location: Location,
source: BoxedError,
},

#[snafu(display("Failed to list {}'s schemas, source: {}", catalog, source))]
#[snafu(display("Failed to list {}'s schemas", catalog))]
ListSchemas {
location: Location,
catalog: String,
source: BoxedError,
},

#[snafu(display(
"Failed to re-compile script due to internal error, source: {}",
source
))]
#[snafu(display("Failed to re-compile script due to internal error"))]
CompileScriptInternal {
location: Location,
source: BoxedError,
},
#[snafu(display("Failed to open system catalog table, source: {}", source))]
#[snafu(display("Failed to open system catalog table"))]
OpenSystemCatalog {
location: Location,
source: table::error::Error,
},

#[snafu(display("Failed to create system catalog table, source: {}", source))]
#[snafu(display("Failed to create system catalog table"))]
CreateSystemCatalog {
location: Location,
source: table::error::Error,
},

#[snafu(display(
"Failed to create table, table info: {}, source: {}",
table_info,
source
))]
#[snafu(display("Failed to create table, table info: {}", table_info))]
CreateTable {
table_info: String,
location: Location,
Expand Down Expand Up @@ -97,13 +90,13 @@ pub enum Error {
#[snafu(display("Catalog value is not present"))]
EmptyValue { location: Location },

#[snafu(display("Failed to deserialize value, source: {}", source))]
#[snafu(display("Failed to deserialize value"))]
ValueDeserialize {
source: serde_json::error::Error,
location: Location,
},

#[snafu(display("Table engine not found: {}, source: {}", engine_name, source))]
#[snafu(display("Table engine not found: {}", engine_name))]
TableEngineNotFound {
engine_name: String,
location: Location,
Expand Down Expand Up @@ -141,14 +134,14 @@ pub enum Error {
#[snafu(display("Operation {} not supported", op))]
NotSupported { op: String, location: Location },

#[snafu(display("Failed to open table {table_id}, source: {source}, at {location}"))]
#[snafu(display("Failed to open table {table_id}"))]
OpenTable {
table_id: TableId,
location: Location,
source: table::error::Error,
},

#[snafu(display("Failed to open table in parallel, source: {}", source))]
#[snafu(display("Failed to open table in parallel"))]
ParallelOpenTable { source: JoinError },

#[snafu(display("Table not found while opening table, table info: {}", table_info))]
Expand All @@ -163,58 +156,52 @@ pub enum Error {
source: common_recordbatch::error::Error,
},

#[snafu(display("Failed to create recordbatch, source: {}", source))]
#[snafu(display("Failed to create recordbatch"))]
CreateRecordBatch {
location: Location,
source: common_recordbatch::error::Error,
},

#[snafu(display(
"Failed to insert table creation record to system catalog, source: {}",
source
))]
#[snafu(display("Failed to insert table creation record to system catalog"))]
InsertCatalogRecord {
location: Location,
source: table::error::Error,
},

#[snafu(display("Failed to scan system catalog table, source: {}", source))]
#[snafu(display("Failed to scan system catalog table"))]
SystemCatalogTableScan {
location: Location,
source: table::error::Error,
},

#[snafu(display("{source}"))]
#[snafu(display(""))]
Internal {
location: Location,
source: BoxedError,
},

#[snafu(display(
"Failed to upgrade weak catalog manager reference. location: {}",
location
))]
#[snafu(display("Failed to upgrade weak catalog manager reference"))]
UpgradeWeakCatalogManagerRef { location: Location },

#[snafu(display("Failed to execute system catalog table scan, source: {}", source))]
#[snafu(display("Failed to execute system catalog table scan"))]
SystemCatalogTableScanExec {
location: Location,
source: common_query::error::Error,
},

#[snafu(display("Cannot parse catalog value, source: {}", source))]
#[snafu(display("Cannot parse catalog value"))]
InvalidCatalogValue {
location: Location,
source: common_catalog::error::Error,
},

#[snafu(display("Failed to perform metasrv operation, source: {}", source))]
#[snafu(display("Failed to perform metasrv operation"))]
MetaSrv {
location: Location,
source: meta_client::error::Error,
},

#[snafu(display("Invalid table info in catalog, source: {}", source))]
#[snafu(display("Invalid table info in catalog"))]
InvalidTableInfoInCatalog {
location: Location,
source: datatypes::error::Error,
Expand All @@ -223,14 +210,14 @@ pub enum Error {
#[snafu(display("Illegal access to catalog: {} and schema: {}", catalog, schema))]
QueryAccessDenied { catalog: String, schema: String },

#[snafu(display("{}: {}", msg, source))]
#[snafu(display("msg: {}", msg))]
Datafusion {
msg: String,
source: DataFusionError,
location: Location,
},

#[snafu(display("Table schema mismatch, source: {}", source))]
#[snafu(display("Table schema mismatch"))]
TableSchemaMismatch {
location: Location,
source: table::error::Error,
Expand All @@ -239,7 +226,7 @@ pub enum Error {
#[snafu(display("A generic error has occurred, msg: {}", msg))]
Generic { msg: String, location: Location },

#[snafu(display("Table metadata manager error: {}", source))]
#[snafu(display("Table metadata manager error"))]
TableMetadataManager {
source: common_meta::error::Error,
location: Location,
Expand Down
20 changes: 6 additions & 14 deletions src/client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,26 @@ pub enum Error {
#[snafu(display("Illegal Flight messages, reason: {}", reason))]
IllegalFlightMessages { reason: String, location: Location },

#[snafu(display("Failed to do Flight get, code: {}, source: {}", tonic_code, source))]
#[snafu(display("Failed to do Flight get, code: {}", tonic_code))]
FlightGet {
addr: String,
tonic_code: Code,
source: BoxedError,
},

#[snafu(display(
"Failure occurs during handling request, location: {}, source: {}",
location,
source
))]
#[snafu(display("Failure occurs during handling request"))]
HandleRequest {
location: Location,
source: BoxedError,
},

#[snafu(display("Failed to convert FlightData, source: {}", source))]
#[snafu(display("Failed to convert FlightData"))]
ConvertFlightData {
location: Location,
source: common_grpc::Error,
},

#[snafu(display("Column datatype error, source: {}", source))]
#[snafu(display("Column datatype error"))]
ColumnDataType {
location: Location,
source: api::error::Error,
Expand All @@ -61,18 +57,14 @@ pub enum Error {
#[snafu(display("Missing required field in protobuf, field: {}", field))]
MissingField { field: String, location: Location },

#[snafu(display(
"Failed to create gRPC channel, peer address: {}, source: {}",
addr,
source
))]
#[snafu(display("Failed to create gRPC channel, peer address: {}", addr))]
CreateChannel {
addr: String,
location: Location,
source: common_grpc::error::Error,
},

#[snafu(display("Failed to request RegionServer, code: {}, source: {}", code, source))]
#[snafu(display("Failed to request RegionServer, code: {}", code))]
RegionServer { code: Code, source: BoxedError },

// Server error carried in Tonic Status's metadata.
Expand Down
Loading

0 comments on commit 20f4f79

Please sign in to comment.