Skip to content

Refine Display implementation for FlightError #5438

Closed
@BugenZhao

Description

@BugenZhao

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrowChanges to the arrow cratearrow-flightChanges to the arrow-flight crateenhancementAny new improvement worthy of a entry in the changelog

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions