entropy_error.hpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // Copyright (c) 2017, 2018 James E. King III
  3. //
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // https://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // Entropy error class
  9. //
  10. #ifndef BOOST_UUID_RANDOM_ENTROPY_ERROR_HPP
  11. #define BOOST_UUID_RANDOM_ENTROPY_ERROR_HPP
  12. #include <boost/config.hpp>
  13. #include <boost/cstdint.hpp>
  14. #include <stdexcept>
  15. #include <string>
  16. namespace boost {
  17. namespace uuids {
  18. //! \brief Given boost::system::system_error is in a module that
  19. //! is not header-only, we define our own exception type
  20. //! to handle entropy provider errors instead,
  21. class BOOST_SYMBOL_VISIBLE entropy_error : public std::runtime_error
  22. {
  23. public:
  24. entropy_error(boost::intmax_t errCode, const std::string& message)
  25. : std::runtime_error(message)
  26. , m_errcode(errCode)
  27. {
  28. }
  29. virtual boost::intmax_t errcode() const
  30. {
  31. return m_errcode;
  32. }
  33. private:
  34. boost::intmax_t m_errcode;
  35. };
  36. } // uuids
  37. } // boost
  38. #endif // BOOST_UUID_RANDOM_ENTROPY_ERROR_HPP