File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -11,13 +11,22 @@ mod parquet_error;
1111mod parser_error;
1212mod 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].
1417pub 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.
2130pub fn tonic_status_to_datafusion_error ( status : & tonic:: Status ) -> Option < DataFusionError > {
2231 if status. code ( ) != tonic:: Code :: Internal {
2332 return None ;
You can’t perform that action at this time.
0 commit comments