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:
Kane York 2020-07-27 19:57:04 -07:00 committed by kanepyork
parent 2a292c71f4
commit 1cbffe21f3
15 changed files with 97 additions and 49 deletions

View file

@ -36,12 +36,15 @@ struct Hash {
Subresource Integrity hash expression). If the 'type' argument
is htUnknown, then the hash type must be specified in the
string. */
Hash(const std::string& s, HashType type = htUnknown);
Hash(std::string_view s, HashType type = htUnknown);
/* Status-returning version of above constructor */
static absl::StatusOr<Hash> deserialize(const std::string& s,
static absl::StatusOr<Hash> deserialize(std::string_view s,
HashType type = htUnknown);
// Legacy unwrapper for StatusOr. Throws BadHash.
static Hash unwrap_throw(absl::StatusOr<Hash> hash) noexcept(false);
void init();
/* Check whether a hash is set. */