channel_error.ipp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // experimental/impl/channel_error.ipp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef ASIO_EXPERIMENTAL_IMPL_CHANNEL_ERROR_IPP
  11. #define ASIO_EXPERIMENTAL_IMPL_CHANNEL_ERROR_IPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #include "asio/experimental/channel_error.hpp"
  17. #include "asio/detail/push_options.hpp"
  18. namespace asio {
  19. namespace experimental {
  20. namespace error {
  21. namespace detail {
  22. class channel_category : public asio::error_category
  23. {
  24. public:
  25. const char* name() const noexcept
  26. {
  27. return "asio.channel";
  28. }
  29. std::string message(int value) const
  30. {
  31. switch (value)
  32. {
  33. case channel_closed: return "Channel closed";
  34. case channel_cancelled: return "Channel cancelled";
  35. default: return "asio.channel error";
  36. }
  37. }
  38. };
  39. } // namespace detail
  40. const asio::error_category& get_channel_category()
  41. {
  42. static detail::channel_category instance;
  43. return instance;
  44. }
  45. } // namespace error
  46. } // namespace experimental
  47. } // namespace asio
  48. #include "asio/detail/pop_options.hpp"
  49. #endif // ASIO_EXPERIMENTAL_IMPL_CHANNEL_ERROR_IPP