eliaperantoni commented on code in PR #13664:
URL: https://github.com/apache/datafusion/pull/13664#discussion_r1872916109


##########
datafusion/common/src/error.rs:
##########
@@ -131,6 +132,7 @@ pub enum DataFusionError {
     /// Errors from either mapping LogicalPlans to/from Substrait plans
     /// or serializing/deserializing protobytes to Substrait plans
     Substrait(String),
+    Diagnostic(Diagnostic, Box<DataFusionError>),

Review Comment:
   Thank you! Yes, I think `DataFusion::Diagnostic` can convey a superset of 
the information that `DataFusion::Context` can. Any wrapping such as:
   
   ```rust
   let error = DataFusionError::Context(message, Box::new(error));
   ```
   
   can be converted to:
   
   ```rust
   let error = DataFusionError::Diagnostic(
        Diagnostic {
                entries: vec![
                        DiagnosticEntry {
                                span: Span::empty(),
                                kind: DiagnosticEntryKind::Error,
                                message,
                        }
                ]
        },
        Box::new(error)
   );
   ```
   
   And of course, we can provide a `DataFusionError::with_simple_diagnostic` 
function to avoid the boilerplate. At that point, `DataFusion::Context` could 
be removed.
   
   This also enables progressively adding `Span` information to what was 
previously simply a string message.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to