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


##########
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:
   In this sense you're right, as a `FlightError` in `Tonic` variant now acts 
as if it is a `tonic::Status`. To obtain a `tonic::Status`, the developer could 
directly match the variants of the enum.
   
   As described in the PR body, I made some variants `transparent` majorly 
because I didn't find appropriate or user-friendly prompts for them. If you 
believe a message like `"Tonic error: ..."` or `"Arrow error: ..."` is good, 
I'm okay to update the `source()` implementation as well.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to