introduce fs-err for sake of better file errors#19
Conversation
3a044fb to
18a9716
Compare
|
Should be merged right after #31 |
3a55349 to
9b0859f
Compare
c9fa70f to
aa71d00
Compare
Xanewok
left a comment
There was a problem hiding this comment.
I continue to have mixed feelings about this...
If this was mostly to replace File::open(T: &Path) and similar with wrapper functions that return a regular File but with an automatically created better messages then I'd feel a lot safer/better.
However, using fs_err:
- seems to spread throughout our public API (because it introduces its own
Filewrapper) - its use already caught me off-guard and
- it seems that this small rewrite potentially introduced a small scope(?)-related bug in
src/dist/cache.rs, because we tried to work around the fact thattempfileworks with regularstd::fs::Path; - using the wrapper type and then converting to
std::fs::Pathboundary forces us to callinto_parts().0(I glanced at the API and didn't notice a better conversion API, sorry if there is one) which seems cryptic and which we could solve already with "proper" error "handling" calls likewith_context(...)
Maybe we could introduce our local util wrapper that automatically only wraps the filename in the error variant only for the File::{open, create} APIs? That should cover most of the uses already and seems like a lower impact change, instead.
src/compiler/compiler.rs
Outdated
There was a problem hiding this comment.
I'd be in favour of never using File but always stick to fs::File everywhere. There are almost no files with more than 2 occurences of File.
There was a problem hiding this comment.
This is more of a code style issue (arguments go both ways) and I'd rather avoid the churn of making changes for the sake of it. Let's keep the diff to a minimum and focus on the easily swapping out std::fs for better errors, which is the reason for this PR.
src/test/utils.rs
Outdated
Yielding better error messages, this is a very easy issue improvement step.
|
@drahnr are you fine with me merging this as-is? |
|
Yes 👍 -> merged |
Ref mozilla/sccache#885