-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Handle missing output directory better #8764
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
Handle missing output directory better #8764
Conversation
|
@aardappel any thoughts on this? |
c82ad9d to
bdb7513
Compare
|
Hmm, I am not sure how I feel about creating a file and then deleting it just for the purpose of seeing if a directory is writable. It seems messy an possibly inefficient. And if all we're doing is checking if the file fails to open for writing, can't we derive that same information from the actual files we're trying to write and produce a better error there? Or just Esp since dirs locked for writing doesn't seem like a frequent occurrence. |
I looked into it and it seems that is unfortunately the most reliable way to check for it.
I guess you are correct that is what we should do. I think i did not go down this path because this requires a bit more refactoring. But since this also came up here that we need a better way to forward errors from the code generators itself i will look into how we could achieve this.
the usecase we had is that src is mounted read-only into the container, and it took us a long time to figure out why flatc was failing. |
bdb7513 to
ee01baa
Compare
|
@aardappel or @jtdavis777 i guess we should not use exceptions? This leaves me with the following option to handle it similar to If thats the way we want to go i would go on and update this mr with replacing all the bool returns with error messages for the useful cases. The example will print error messages like this (note the message at the end) -> |
|
Yes, this project has always been under the google C++ guidelines, which have always forbidden exceptions. Your solution seems good to me. |
Improve the error message when the output directory is not writable.
After:
Before:
This runs only if the cpp version is 17 or higher since writing this check platform independent without std::filesystem would be a huge pain and a lot more code. Pre cpp17 versions will just fall back to the error message from before and assume the directory is always writable.