Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine Display implementation for FlightError #5438

Closed
BugenZhao opened this issue Feb 27, 2024 · 2 comments · Fixed by #5439
Closed

Refine Display implementation for FlightError #5438

BugenZhao opened this issue Feb 27, 2024 · 2 comments · Fixed by #5439
Labels
arrow Changes to the arrow crate arrow-flight Changes to the arrow-flight crate enhancement Any new improvement worthy of a entry in the changelog

Comments

@BugenZhao
Copy link
Contributor

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

There's a TODO for a better std::fmt::Display implementation on FlightError. Currently it forwards to std::fmt::Debug, which does not appear to be a good practice as errors should describe themselves with friendly messages provided by Display.

impl std::fmt::Display for FlightError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// TODO better format / error
write!(f, "{self:?}")
}
}

Describe the solution you'd like

Match the variants of the error and specify different prompts like what we did for ArrowError.

impl Display for ArrowError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
ArrowError::NotYetImplemented(source) => {
write!(f, "Not yet implemented: {}", &source)
}
ArrowError::ExternalError(source) => write!(f, "External error: {}", &source),
ArrowError::CastError(desc) => write!(f, "Cast error: {desc}"),
ArrowError::MemoryError(desc) => write!(f, "Memory error: {desc}"),

Describe alternatives you've considered

Derive the implementation with thiserror. The code can be more concise with the cost of introducing a new build-time dependency.

Additional context

A better practice to implement Display for errors is NOT to include the error source. AWS SDK has adopted this as described in awslabs/aws-sdk-rust#657. However, this could be considered as a breaking change as many developers have not realize that one should leverage something like std::error::Report to get the error sources printed.

@BugenZhao BugenZhao added the enhancement Any new improvement worthy of a entry in the changelog label Feb 27, 2024
@tustvold tustvold added the arrow Changes to the arrow crate label Mar 1, 2024
@tustvold
Copy link
Contributor

tustvold commented Mar 1, 2024

label_issue.py automatically added labels {'arrow'} from #5439

@tustvold tustvold added the arrow-flight Changes to the arrow-flight crate label Mar 1, 2024
@tustvold
Copy link
Contributor

tustvold commented Mar 1, 2024

label_issue.py automatically added labels {'arrow-flight'} from #5439

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate arrow-flight Changes to the arrow-flight crate enhancement Any new improvement worthy of a entry in the changelog
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants