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 <grfn@gws.fyi> Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
parent
2a292c71f4
commit
1cbffe21f3
15 changed files with 97 additions and 49 deletions
17
third_party/nix/src/libexpr/primops.cc
vendored
17
third_party/nix/src/libexpr/primops.cc
vendored
|
|
@ -704,7 +704,8 @@ static void prim_derivationStrict(EvalState& state, const Pos& pos,
|
|||
|
||||
HashType ht =
|
||||
outputHashAlgo.empty() ? htUnknown : parseHashType(outputHashAlgo);
|
||||
Hash h(*outputHash, ht);
|
||||
auto hash_ = Hash::deserialize(*outputHash, ht);
|
||||
auto h = Hash::unwrap_throw(hash_);
|
||||
|
||||
Path outPath =
|
||||
state.store->makeFixedOutputPath(outputHashRecursive, h, drvName);
|
||||
|
|
@ -1144,9 +1145,10 @@ static void prim_path(EvalState& state, const Pos& pos, Value** args,
|
|||
} else if (n == "recursive") {
|
||||
recursive = state.forceBool(*attr.second.value, *attr.second.pos);
|
||||
} else if (n == "sha256") {
|
||||
expectedHash =
|
||||
Hash(state.forceStringNoCtx(*attr.second.value, *attr.second.pos),
|
||||
htSHA256);
|
||||
auto hash_ = Hash::deserialize(
|
||||
state.forceStringNoCtx(*attr.second.value, *attr.second.pos),
|
||||
htSHA256);
|
||||
expectedHash = Hash::unwrap_throw(hash_);
|
||||
} else {
|
||||
throw EvalError(
|
||||
format("unsupported argument '%1%' to 'addPath', at %2%") %
|
||||
|
|
@ -2077,9 +2079,10 @@ void fetch(EvalState& state, const Pos& pos, Value** args, Value& v,
|
|||
request.uri =
|
||||
state.forceStringNoCtx(*attr.second.value, *attr.second.pos);
|
||||
} else if (n == "sha256") {
|
||||
request.expectedHash =
|
||||
Hash(state.forceStringNoCtx(*attr.second.value, *attr.second.pos),
|
||||
htSHA256);
|
||||
auto hash_ = Hash::deserialize(
|
||||
state.forceStringNoCtx(*attr.second.value, *attr.second.pos),
|
||||
htSHA256);
|
||||
request.expectedHash = Hash::unwrap_throw(hash_);
|
||||
} else if (n == "name") {
|
||||
request.name =
|
||||
state.forceStringNoCtx(*attr.second.value, *attr.second.pos);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue