fix: Fix inconsistencies with error messages across targets #51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The easy part:
There was a typo in the error conversion code causing
Enotdirto come through asUnknown("ENOTDIR")on the JS target. I've simply fixed the typo.The hard part:
There is an inconsistency with the error messages returned for
create_directory_allwhen the caller doesn't have permissions for the provided path.It comes down to the behavior of
file:make_dirin erlang, which is called byfilelib:ensure_pathwhich is called by simplifile. From the function's docs:I'm quite certain there are more inconsistencies like this in simplifile, where the particular error returned varies by the unique combination of runtime and platform. I wrote a custom ensure_dir impl that made the error consistent, but it relied on an extra sys call in the recursion, which didn't feel like a worthwhile tradeoff.
In general, I would like simplifile's behavior to be "as consistent as possible" across the runtimes on different platforms, so I'll keep looking into solutions here.
fixes #50