Skip to content

Commit 0f8e7c5

Browse files
committed
Add docs
1 parent 6b9263a commit 0f8e7c5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/errors/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,22 @@ mod parquet_error;
1111
mod parser_error;
1212
mod schema_error;
1313

14+
/// Encodes a [DataFusionError] into a [tonic::Status] error. The produced error is suitable
15+
/// to be sent over the wire and decoded by the receiving end, recovering the original
16+
/// [DataFusionError] across a network boundary with [tonic_status_to_datafusion_error].
1417
pub fn datafusion_error_to_tonic_status(err: &DataFusionError) -> tonic::Status {
1518
let err = DataFusionErrorProto::from_datafusion_error(err);
1619
let err = err.encode_to_vec();
1720
let status = tonic::Status::with_details(tonic::Code::Internal, "DataFusionError", err.into());
1821
status
1922
}
2023

24+
/// Decodes a [DataFusionError] from a [tonic::Status] error. If the provided [tonic::Status]
25+
/// error was produced with [datafusion_error_to_tonic_status], this function will be able to
26+
/// recover it even across a network boundary.
27+
///
28+
/// The provided [tonic::Status] error might also be something else, like an actual network
29+
/// failure. This function returns `None` for those cases.
2130
pub fn tonic_status_to_datafusion_error(status: &tonic::Status) -> Option<DataFusionError> {
2231
if status.code() != tonic::Code::Internal {
2332
return None;

0 commit comments

Comments
 (0)