/* * TLS Stream Errors * (C) 2018-2019 Jack Lloyd * 2018-2019 Hannes Rantzsch, Tim Oesterreich, Rene Meusel * * Botan is released under the Simplified BSD License (see license.txt) */ #ifndef BOTAN_ASIO_ERROR_H_ #define BOTAN_ASIO_ERROR_H_ #include #include #if BOOST_VERSION >= 106600 #include #include #include #include namespace Botan { namespace TLS { namespace detail { // TLS Alerts struct BotanAlertCategory : boost::system::error_category { const char* name() const noexcept override { return "asio.botan.tls.alert"; } std::string message(int ev) const override { Botan::TLS::Alert alert(static_cast(ev)); return alert.type_string(); } }; inline const BotanAlertCategory& botan_alert_category() noexcept { static BotanAlertCategory category; return category; } struct BotanErrorCategory : boost::system::error_category { const char* name() const noexcept override { return "asio.botan.tls"; } std::string message(int ev) const override { return Botan::to_string(static_cast(ev)); } }; inline const BotanErrorCategory& botan_category() noexcept { static BotanErrorCategory category; return category; } } // namespace detail inline boost::system::error_code make_error_code(Botan::TLS::Alert::Type c) { return boost::system::error_code(static_cast(c), detail::botan_alert_category()); } } // namespace TLS inline boost::system::error_code make_error_code(Botan::ErrorType e) { return boost::system::error_code(static_cast(e), Botan::TLS::detail::botan_category()); } } // namespace Botan namespace boost { namespace system { template<> struct is_error_code_enum { static const bool value = true; }; template<> struct is_error_code_enum { static const bool value = true; }; } // namespace system } // namespace boost #endif // BOOST_VERSION #endif // BOTAN_ASIO_ERROR_H_