entropy_error.hpp 1017 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // Copyright (c) 2017 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. // http://www.boost.org/LICENCE_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/cstdint.hpp>
  13. #include <stdexcept>
  14. #include <string>
  15. namespace boost {
  16. namespace uuids {
  17. //! \brief Given boost::system::system_error is in a module that
  18. //! is not header-only, we define our own exception type
  19. //! to handle entropy provider errors instead,
  20. class entropy_error : public std::runtime_error
  21. {
  22. public:
  23. entropy_error(boost::intmax_t errCode, const std::string& message)
  24. : std::runtime_error(message)
  25. , m_errcode(errCode)
  26. {
  27. }
  28. virtual boost::intmax_t errcode() const
  29. {
  30. return m_errcode;
  31. }
  32. private:
  33. boost::intmax_t m_errcode;
  34. };
  35. } // uuids
  36. } // boost
  37. #endif // BOOST_UUID_RANDOM_ENTROPY_ERROR_HPP