entropy_error.hpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef BOOST_UUID_ENTROPY_ERROR_HPP_INCLUDED
  2. #define BOOST_UUID_ENTROPY_ERROR_HPP_INCLUDED
  3. //
  4. // Copyright (c) 2017, 2018 James E. King III
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // (See accompanying file LICENSE_1_0.txt or copy at
  8. // https://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // Entropy error class
  11. //
  12. #include <boost/config.hpp>
  13. #include <stdexcept>
  14. #include <string>
  15. #include <cstdint>
  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(std::intmax_t errCode, const std::string& message)
  25. : std::runtime_error(message)
  26. , m_errcode(errCode)
  27. {
  28. }
  29. virtual std::intmax_t errcode() const
  30. {
  31. return m_errcode;
  32. }
  33. private:
  34. std::intmax_t m_errcode;
  35. };
  36. } // uuids
  37. } // boost
  38. #endif // BOOST_UUID_ENTROPY_ERROR_HPP_INCLUDED