Nagram/TMessagesProj/jni/voip/webrtc/absl/random/seed_gen_exception.cc

47 lines
1.2 KiB
C++
Raw Normal View History

2020-03-30 12:00:09 +00:00
// Copyright 2017 The Abseil Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
2020-08-14 16:58:22 +00:00
// https://www.apache.org/licenses/LICENSE-2.0
2020-03-30 12:00:09 +00:00
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
2020-08-14 16:58:22 +00:00
#include "absl/random/seed_gen_exception.h"
2020-03-30 12:00:09 +00:00
2020-08-14 16:58:22 +00:00
#include <iostream>
2020-03-30 12:00:09 +00:00
#include "absl/base/config.h"
namespace absl {
2020-08-14 16:58:22 +00:00
ABSL_NAMESPACE_BEGIN
static constexpr const char kExceptionMessage[] =
"Failed generating seed-material for URBG.";
2020-03-30 12:00:09 +00:00
2020-08-14 16:58:22 +00:00
SeedGenException::~SeedGenException() = default;
2020-03-30 12:00:09 +00:00
2020-08-14 16:58:22 +00:00
const char* SeedGenException::what() const noexcept {
return kExceptionMessage;
2020-03-30 12:00:09 +00:00
}
2020-08-14 16:58:22 +00:00
namespace random_internal {
2020-03-30 12:00:09 +00:00
2020-08-14 16:58:22 +00:00
void ThrowSeedGenException() {
2020-03-30 12:00:09 +00:00
#ifdef ABSL_HAVE_EXCEPTIONS
2020-08-14 16:58:22 +00:00
throw absl::SeedGenException();
2020-03-30 12:00:09 +00:00
#else
2020-08-14 16:58:22 +00:00
std::cerr << kExceptionMessage << std::endl;
std::terminate();
2020-03-30 12:00:09 +00:00
#endif
}
2020-08-14 16:58:22 +00:00
} // namespace random_internal
ABSL_NAMESPACE_END
2020-03-30 12:00:09 +00:00
} // namespace absl