diff options
author | Hannes Rantzsch <[email protected]> | 2019-04-23 16:17:39 +0200 |
---|---|---|
committer | Hannes Rantzsch <[email protected]> | 2019-04-23 16:17:39 +0200 |
commit | cd0580600fd3bbdd49fe60a1333c5ea5df9d5bfc (patch) | |
tree | 3e4f988bc97a945f5cd7a1f36d8bbe7bf1226c83 | |
parent | 968beff9e28ff0f32e662dfd4fa8e5287cfd2abb (diff) |
remove convertException entirely
-rw-r--r-- | src/lib/tls/asio/asio_async_handshake_op.h | 13 | ||||
-rw-r--r-- | src/lib/tls/asio/asio_async_read_op.h | 13 | ||||
-rw-r--r-- | src/lib/tls/asio/asio_error.h | 25 | ||||
-rw-r--r-- | src/lib/tls/asio/asio_stream.h | 58 |
4 files changed, 73 insertions, 36 deletions
diff --git a/src/lib/tls/asio/asio_async_handshake_op.h b/src/lib/tls/asio/asio_async_handshake_op.h index 670af373c..23875ba7f 100644 --- a/src/lib/tls/asio/asio_async_handshake_op.h +++ b/src/lib/tls/asio/asio_async_handshake_op.h @@ -14,6 +14,7 @@ #include <boost/version.hpp> #if BOOST_VERSION >= 106600 +#include <botan/asio_error.h> #include <botan/internal/asio_async_write_op.h> #include <botan/internal/asio_includes.h> #include <botan/internal/asio_stream_core.h> @@ -65,9 +66,17 @@ class AsyncHandshakeOperation : public AsyncBase<Handler, typename Stream::execu { m_stream.native_handle()->received_data(static_cast<const uint8_t*>(read_buffer.data()), read_buffer.size()); } - catch(const std::exception&) + catch(const TLS_Exception& e) { - ec = convertException(); + ec = e.type(); + } + catch(const Botan::Exception& e) + { + ec = e.error_type(); + } + catch(...) + { + ec = Botan::ErrorType::Unknown; } } diff --git a/src/lib/tls/asio/asio_async_read_op.h b/src/lib/tls/asio/asio_async_read_op.h index b15e273b9..5902fd388 100644 --- a/src/lib/tls/asio/asio_async_read_op.h +++ b/src/lib/tls/asio/asio_async_read_op.h @@ -14,6 +14,7 @@ #include <boost/version.hpp> #if BOOST_VERSION >= 106600 +#include <botan/asio_error.h> #include <botan/internal/asio_async_base.h> #include <botan/internal/asio_includes.h> #include <botan/internal/asio_stream_core.h> @@ -69,9 +70,17 @@ class AsyncReadOperation : public AsyncBase<Handler, typename Stream::executor_t m_stream.native_handle()->received_data(static_cast<const uint8_t*>(read_buffer.data()), read_buffer.size()); } - catch(const std::exception&) + catch(const TLS_Exception& e) { - ec = convertException(); + ec = e.type(); + } + catch(const Botan::Exception& e) + { + ec = e.error_type(); + } + catch(...) + { + ec = Botan::ErrorType::Unknown; } } diff --git a/src/lib/tls/asio/asio_error.h b/src/lib/tls/asio/asio_error.h index 92f54ba7c..4e59a6906 100644 --- a/src/lib/tls/asio/asio_error.h +++ b/src/lib/tls/asio/asio_error.h @@ -54,7 +54,7 @@ struct BotanErrorCategory : boost::system::error_category std::string message(int ev) const override { - return Botan::to_string(static_cast<Botan::ErrorType>(ev)); + return Botan::to_string(static_cast<Botan::ErrorType>(ev)); } }; @@ -96,28 +96,5 @@ template<> struct is_error_code_enum<Botan::ErrorType> } // namespace system } // namespace boost -namespace Botan { -namespace TLS { - -inline boost::system::error_code convertException() - { - try - { - throw; - } - catch(const TLS_Exception& e) - { - return e.type(); - } - catch(const Botan::Exception& e) - { - return e.error_type(); - } - } - -} // namespace system -} // namespace boost - - #endif // BOOST_VERSION #endif // BOTAN_ASIO_ERROR_H_ diff --git a/src/lib/tls/asio/asio_stream.h b/src/lib/tls/asio/asio_stream.h index 8318c3c4e..1654aa658 100644 --- a/src/lib/tls/asio/asio_stream.h +++ b/src/lib/tls/asio/asio_stream.h @@ -191,9 +191,19 @@ class Stream : public StreamBase<Channel> native_handle()->received_data(static_cast<const uint8_t*>(read_buffer.data()), read_buffer.size()); } - catch(const std::exception& ex) + catch(const TLS_Exception& e) { - ec = Botan::TLS::convertException(); + ec = e.type(); + return; + } + catch(const Botan::Exception& e) + { + ec = e.error_type(); + return; + } + catch(const std::exception &) + { + ec = Botan::ErrorType::Unknown; return; } @@ -329,11 +339,22 @@ class Stream : public StreamBase<Channel> { native_handle()->close(); } - catch(const std::exception& ex) + catch(const TLS_Exception& e) { - ec = Botan::TLS::convertException(); + ec = e.type(); return; } + catch(const Botan::Exception& e) + { + ec = e.error_type(); + return; + } + catch(const std::exception &) + { + ec = Botan::ErrorType::Unknown; + return; + } + sendPendingEncryptedData(ec); } @@ -531,9 +552,20 @@ class Stream : public StreamBase<Channel> native_handle()->received_data(static_cast<const uint8_t*>(read_buffer.data()), read_buffer.size()); } - catch(const std::exception& ex) + catch(const TLS_Exception& e) { - ec = Botan::TLS::convertException(); + ec = e.type(); + return; + } + catch(const Botan::Exception& e) + { + ec = e.error_type(); + return; + } + catch(const std::exception &) + { + ec = Botan::ErrorType::Unknown; + return; } } @@ -559,9 +591,19 @@ class Stream : public StreamBase<Channel> { native_handle()->send(static_cast<const uint8_t*>(buffer.data()), amount); } - catch(const std::exception&) + catch(const TLS_Exception& e) + { + ec = e.type(); + return 0; + } + catch(const Botan::Exception& e) + { + ec = e.error_type(); + return 0; + } + catch(const std::exception &) { - ec = Botan::TLS::convertException(); + ec = Botan::ErrorType::Unknown; return 0; } sent += amount; |