1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-29 14:53:16 +02:00

refactor: Remove throw from queryPathInfoFromClientCache

Return a value instead of throwing.

Rather than the more trivial refactor of wrapping the return value in
another std::optional, we retain the meaning of the outer optional:
"we know at least something."

So we have changed:
return nullopt    -> return nullopt
throw InvalidPath -> return make_optional(nullptr)
return vpi        -> return make_optional(vpi)
This commit is contained in:
Robert Hensing 2024-01-19 17:00:39 +01:00
parent 8983ee8b2e
commit d19627e8b4
2 changed files with 18 additions and 14 deletions

View file

@ -283,16 +283,14 @@ public:
Callback<ref<const ValidPathInfo>> callback) noexcept;
/**
* NOTE: this is not the final interface - to be modified in next commit.
*
* Version of queryPathInfo() that only queries the local narinfo cache and not
* the actual store.
*
* @return `std::make_optional(vpi)` if the path is known
* @return `std::null_opt` if the path was not known to be valid or invalid
* @throw InvalidPathError if the path is known to be invalid
* @return `std::nullopt` if nothing is known about the path in the local narinfo cache.
* @return `std::make_optional(nullptr)` if the path is known to not exist.
* @return `std::make_optional(validPathInfo)` if the path is known to exist.
*/
std::optional<ref<const ValidPathInfo>> queryPathInfoFromClientCache(const StorePath & path);
std::optional<std::shared_ptr<const ValidPathInfo>> queryPathInfoFromClientCache(const StorePath & path);
/**
* Query the information about a realisation.