Check the error code and save a call to sys::fs::exists.