-
Notifications
You must be signed in to change notification settings - Fork 61
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
Automatically detect and remove nested error messages in Report output #363
Comments
Well, so long as the algorithm can be disabled in controlled scenarios where we know this doesn't happen, it sounds like a nice idea. I just wonder what the phasing out strategy would be, considering that this would also hide the fact that some libraries are not following the official recommendation from the error handling WG. |
I'm not sure I follow your meaning — can you expand on it a bit? I'm pretty sure that to do this we would need allocation, so we will rely on the standard library. In that case we could use an environment variable to turn it off.
One possibility would be to track if we made any changes and if so append another line (maybe even a symbol next to the offending lines?) to explain what happened and how to remove it:
|
I'm thinking that eventually most dependencies' errors would be well behaved in terms of their The redundant information removal notice seems fine too. |
fn main() {
let orig = vec![
"error sending request for url (https://rust-lasagna.org/): error trying to connect: dns error: failed to lookup address information: nodename nor servname provided, or not known",
"error trying to connect: dns error: failed to lookup address information: nodename nor servname provided, or not known",
"dns error: failed to lookup address information: nodename nor servname provided, or not known",
"failed to lookup address information: nodename nor servname provided, or not known",
];
let mut clean = Vec::with_capacity(orig.len());
clean.extend(
orig.iter()
.zip(orig.iter().skip(1))
.map(|(a, b)| a.trim_end_matches(b).trim_end().trim_end_matches(":")),
);
clean.extend(orig.last());
dbg!(clean);
} |
An example reqwest error:
We could attempt to remove the substring of the next error:
Proposed algorithm would be to use
str::trim_end_matches
, trim trailing whitespace, then a trailing:
.Then the output would look something like...
The text was updated successfully, but these errors were encountered: