use precondition instead of runtime exception (#2421)

This commit is contained in:
JinmingHu 2021-06-08 11:46:57 +08:00 committed by GitHub
parent 686270743d
commit 83c265b463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -151,10 +151,8 @@ namespace Azure { namespace Storage {
std::vector<uint8_t> Sha256(const std::vector<uint8_t>& data)
{
if (data.size() > std::numeric_limits<ULONG>::max())
{
throw std::runtime_error("Data size is too big.");
}
AZURE_ASSERT_MSG(data.size() <= std::numeric_limits<ULONG>::max(), "Data size is too big.");
static AlgorithmProviderInstance AlgorithmProvider(AlgorithmType::Sha256);
std::string context;
@ -202,10 +200,7 @@ namespace Azure { namespace Storage {
const std::vector<uint8_t>& data,
const std::vector<uint8_t>& key)
{
if (data.size() > std::numeric_limits<ULONG>::max())
{
throw std::runtime_error("Data size is too big.");
}
AZURE_ASSERT_MSG(data.size() <= std::numeric_limits<ULONG>::max(), "Data size is too big.");
static AlgorithmProviderInstance AlgorithmProvider(AlgorithmType::HmacSha256);