error.ipp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/beast
  8. //
  9. #ifndef BOOST_BEAST_TEST_IMPL_ERROR_IPP
  10. #define BOOST_BEAST_TEST_IMPL_ERROR_IPP
  11. namespace boost {
  12. namespace beast {
  13. namespace test {
  14. namespace detail {
  15. inline
  16. const char*
  17. error_codes::
  18. name() const noexcept
  19. {
  20. return "boost.beast.test";
  21. }
  22. inline
  23. std::string
  24. error_codes::
  25. message(int ev) const
  26. {
  27. switch(static_cast<error>(ev))
  28. {
  29. default:
  30. case error::test_failure: return "The test stream generated a simulated error";
  31. }
  32. }
  33. inline
  34. error_condition
  35. error_codes::
  36. default_error_condition(int ev) const noexcept
  37. {
  38. return error_condition{ev, *this};
  39. }
  40. } // detail
  41. inline
  42. error_code
  43. make_error_code(error e)
  44. {
  45. static detail::error_codes const cat{};
  46. return error_code{static_cast<
  47. std::underlying_type<error>::type>(e), cat};
  48. }
  49. } // test
  50. } // beast
  51. } // boost
  52. #endif