Skip to content

Commit

Permalink
Elaborate the "unknown hash algorithm" error
Browse files Browse the repository at this point in the history
List the allowed hash formats
  • Loading branch information
ShamrockLee committed Oct 18, 2023
1 parent e9ddf0b commit aff177d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/libexpr/tests/error_traces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ namespace nix {

ASSERT_TRACE1("hashString \"foo\" \"content\"",
UsageError,
hintfmt("unknown hash algorithm '%s'", "foo"));
hintfmt("unknown hash algorithm '%s', expect 'md5', 'sha1', 'sha256', or 'sha512'", "foo"));

ASSERT_TRACE2("hashString \"sha256\" {}",
TypeError,
Expand Down
2 changes: 1 addition & 1 deletion src/libutil/hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ HashType parseHashType(std::string_view s)
if (opt_h)
return *opt_h;
else
throw UsageError("unknown hash algorithm '%1%'", s);
throw UsageError("unknown hash algorithm '%1%', expect 'md5', 'sha1', 'sha256', or 'sha512'", s);
}

std::string_view printHashType(HashType ht)
Expand Down

0 comments on commit aff177d

Please sign in to comment.