You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that there is no simple way to get a detailed message of an error without direct matching on Error variants, or without using Debug, because the Display impl for Error ignores the message:
This interferes with generic error handling using libraries like failure - you cannot easily present a generic error to the user if it contains httpbis::error::Error. For example, suppose I have code like this (using rust-grpc):
fnstart_server(config:Config) -> Result<(), failure::Error>{letmut server_builder = grpc::ServerBuilder::new_plain();
server_builder.http.set_addr(&config.address).context("Failed to set address")?;
...}
set_addr returns httpbis::error::Error, and it may fail if e.g. hostname in the address resolves to many addresses. If I use this code and I try to print the error chain when the address is incorrect, I get this:
% ./target/debug/iprlist server
[E] [iprlist] Failed to set address
[E] [iprlist] HTTP/2 Error: An unknown error
which is completely opaque and user-unfriendly. And there is no simple way to show a more detailed error message, because the httpbis error is wrapped into failure::Context and failure::Error, and it would require downcasting and matching on all httpbis::error::Error enum variants to get a proper error message. Moreover, as far as I can see, this is not limited to the Error::Other variant - variants like Error::IoError are also displayed without any details.
In my opinion, the Display impl should display the underlying error, if there is any, instead of forwarding to description().
The text was updated successfully, but these errors were encountered:
I found that there is no simple way to get a detailed message of an error without direct matching on
Error
variants, or without usingDebug
, because theDisplay
impl forError
ignores the message:This interferes with generic error handling using libraries like
failure
- you cannot easily present a generic error to the user if it containshttpbis::error::Error
. For example, suppose I have code like this (using rust-grpc):set_addr
returnshttpbis::error::Error
, and it may fail if e.g. hostname in the address resolves to many addresses. If I use this code and I try to print the error chain when the address is incorrect, I get this:which is completely opaque and user-unfriendly. And there is no simple way to show a more detailed error message, because the httpbis error is wrapped into
failure::Context
andfailure::Error
, and it would require downcasting and matching on allhttpbis::error::Error
enum variants to get a proper error message. Moreover, as far as I can see, this is not limited to theError::Other
variant - variants likeError::IoError
are also displayed without any details.In my opinion, the
Display
impl should display the underlying error, if there is any, instead of forwarding todescription()
.The text was updated successfully, but these errors were encountered: