From 1cbffe21f3284fbad10b4ca27b0d8381bd554ff3 Mon Sep 17 00:00:00 2001 From: Kane York Date: Mon, 27 Jul 2020 19:57:04 -0700 Subject: chore(3p/nix/hash): prefer StatusOr over throwing constructor The use of `unwrap_throw` can be used as a later grep target. Change-Id: I8c54ed90c4289f07aecb8a1393dd10204c8bce4e Reviewed-on: https://cl.tvl.fyi/c/depot/+/1493 Reviewed-by: glittershark Reviewed-by: tazjin Tested-by: BuildkiteCI --- third_party/nix/src/libstore/local-store.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'third_party/nix/src/libstore/local-store.cc') diff --git a/third_party/nix/src/libstore/local-store.cc b/third_party/nix/src/libstore/local-store.cc index c513e3ac4e9d..14ba580654ab 100644 --- a/third_party/nix/src/libstore/local-store.cc +++ b/third_party/nix/src/libstore/local-store.cc @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -681,11 +682,12 @@ void LocalStore::queryPathInfoUncached( info->id = useQueryPathInfo.getInt(0); - try { - info->narHash = Hash(useQueryPathInfo.getStr(1)); - } catch (BadHash& e) { - throw Error("in valid-path entry for '%s': %s", path, e.what()); + auto hash_ = Hash::deserialize(useQueryPathInfo.getStr(1)); + if (!hash_.ok()) { + throw Error(absl::StrCat("in valid-path entry for '", path, + "': ", hash_.status().ToString())); } + info->narHash = *hash_; info->registrationTime = useQueryPathInfo.getInt(2); -- cgit 1.4.1