move-language / move

Apache License 2.0
2.25k stars 679 forks source link

[tools] Add `try_exists` that surfaces other files issues if the file exists but has an error #1011

Closed tzakian closed 1 year ago

tzakian commented 1 year ago

std::path::exists collapses all errors to false however if we want to be able to return more fine-grained issues back we need to surface these errors as well.

This adds a try_exist function that only returns false if the file actually doesn't exist. Otherwise if there's a different error this will return an Err result. This PR then plumbs this into a few cases where either (1) we should really return an error if the file has an issue (vs, we can recover from it without too many issues); or (2) where we then use this information to surface an error that the file doesn't exist.