Skip to content
This repository was archived by the owner on Feb 28, 2023. It is now read-only.

Comments

introduce fs-err for sake of better file errors#19

Merged
drahnr merged 1 commit intomasterfrom
bernhard-fs-err
May 18, 2021
Merged

introduce fs-err for sake of better file errors#19
drahnr merged 1 commit intomasterfrom
bernhard-fs-err

Conversation

@drahnr
Copy link
Contributor

@drahnr drahnr commented Nov 19, 2020

@drahnr drahnr self-assigned this Nov 19, 2020
@drahnr drahnr requested a review from TriplEight November 19, 2020 12:13
TriplEight
TriplEight previously approved these changes Nov 20, 2020
Copy link
Contributor

@TriplEight TriplEight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@drahnr
Copy link
Contributor Author

drahnr commented Apr 8, 2021

Should be merged right after #31

@drahnr drahnr force-pushed the bernhard-fs-err branch 5 times, most recently from 3a55349 to 9b0859f Compare May 4, 2021 14:14
@drahnr drahnr force-pushed the bernhard-fs-err branch 6 times, most recently from c9fa70f to aa71d00 Compare May 5, 2021 07:58
@drahnr drahnr requested a review from TriplEight May 5, 2021 08:07
@drahnr drahnr force-pushed the bernhard-fs-err branch from aa71d00 to a032d32 Compare May 10, 2021 09:19
@Xanewok
Copy link
Contributor

Xanewok commented May 10, 2021

Pushed 36b00f4 and e720b9a to see if this fixes CI (can confirm locally)

Copy link
Contributor

@Xanewok Xanewok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. seems to spread throughout our public API (because it introduces its own File wrapper)
  2. its use already caught me off-guard and
  3. 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 that tempfile works with regular std::fs::Path;
  4. using the wrapper type and then converting to std::fs::Path boundary forces us to call into_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 like with_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.

@Xanewok Xanewok force-pushed the bernhard-fs-err branch from 860b8a5 to a456390 Compare May 18, 2021 09:29
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Xanewok Xanewok force-pushed the bernhard-fs-err branch from a456390 to 94e71a3 Compare May 18, 2021 09:38
Yielding better error messages, this is a very easy issue
improvement step.
@Xanewok Xanewok force-pushed the bernhard-fs-err branch from 94e71a3 to 5c844aa Compare May 18, 2021 09:43
@Xanewok
Copy link
Contributor

Xanewok commented May 18, 2021

@drahnr are you fine with me merging this as-is?

@drahnr drahnr merged commit 6038b29 into master May 18, 2021
@drahnr drahnr deleted the bernhard-fs-err branch May 18, 2021 10:39
@drahnr
Copy link
Contributor Author

drahnr commented May 18, 2021

Yes 👍 -> merged

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants