tustvold commented on code in PR #5439:
URL: https://github.com/apache/arrow-rs/pull/5439#discussion_r1507039900


##########
arrow-flight/src/error.rs:
##########
@@ -49,17 +49,24 @@ impl FlightError {
 
 impl std::fmt::Display for FlightError {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        // TODO better format / error
-        write!(f, "{self:?}")
+        match self {
+            FlightError::Arrow(inner) => inner.fmt(f),
+            FlightError::NotYetImplemented(desc) => write!(f, "Not yet 
implemented: {}", desc),
+            FlightError::Tonic(inner) => inner.fmt(f),
+            FlightError::ProtocolError(desc) => write!(f, "Protocol error: 
{}", desc),
+            FlightError::DecodeError(desc) => write!(f, "Decode error: {}", 
desc),
+            FlightError::ExternalError(source) => write!(f, "External error: 
{}", source),
+        }
     }
 }
 
 impl Error for FlightError {
     fn source(&self) -> Option<&(dyn Error + 'static)> {
-        if let Self::ExternalError(e) = self {
-            Some(e.as_ref())
-        } else {
-            None
+        match self {
+            FlightError::Arrow(inner) => inner.source(),

Review Comment:
   So the use-case for returning `tonic::Status` in source might be if 
FlightError was wrapped itself inside another error, potentially an opaque one, 
a user might want to walk the source chain to find `tonic::Status` in order to 
get the error code or something



-- 
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...@arrow.apache.org

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

Reply via email to