-
Notifications
You must be signed in to change notification settings - Fork 118
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
Handling unwrap errors in lib.rs #99
Conversation
"Failed to find path" does not seem to be a very helpful message when the actual problem is a non-UTF8 path. |
Turns out there was another one I was hitting, so I've updated that as well. |
Are these unwraps getting hit frequently in practice? I think it's fine to get a better error message for when they are hit but if it's frequent then I'd want to fix the underlying issue ideally. |
I had the issue, and looking in the issues for this project, it looks like the following tickets are related: #30, #47, #94. My issue was that I was missing |
src/lib.rs
Outdated
let status = match command.status() { | ||
Ok(value) => value, | ||
Err(error) => { | ||
panic!("Error running command {:?} => {:?}", command, error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the command needs to be printed again because it was already printed a few lines above this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
None => { | ||
panic!("Failed to convert path to string: {:?}", &path); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this and the above to_str
use a helper function instead of duplicating?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably
This blind unwrap seems to be a very common error in builds, when it panics it gives the end user no clear way of identifying what's wrong, this PR adds some handling to show the file path that can't be found.