Improve reporting of socket errors.
authorCarl Hetherington <cth@carlh.net>
Wed, 19 Mar 2025 23:13:15 +0000 (00:13 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 22 Mar 2025 12:29:58 +0000 (13:29 +0100)
src/lib/dcpomatic_socket.cc

index 9ccbd0af8418f6426853bb8eb881e0e2ca3a023c..9507128a2752832c638a3efce0b7eefe10926687 100644 (file)
@@ -24,6 +24,7 @@
 #include "dcpomatic_log.h"
 #include "dcpomatic_socket.h"
 #include "exceptions.h"
+#include "util.h"
 #include <fmt/format.h>
 #include <boost/bind/bind.hpp>
 #include <boost/lambda/lambda.hpp>
@@ -75,7 +76,7 @@ Socket::connect(boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> en
        } while (ec == boost::asio::error::would_block);
 
        if (ec) {
-               throw NetworkError (String::compose (_("error during async_connect (%1)"), ec.value ()));
+               throw NetworkError(String::compose(_("error during async_connect: (%1)"), error_details(ec)));
        }
 
        if (!_socket.is_open ()) {
@@ -105,7 +106,7 @@ Socket::connect(boost::asio::ip::tcp::endpoint endpoint)
        } while (ec == boost::asio::error::would_block);
 
        if (ec) {
-               throw NetworkError (String::compose (_("error during async_connect (%1)"), ec.value ()));
+               throw NetworkError(String::compose(_("error during async_connect (%1)"), error_details(ec)));
        }
 
        if (!_socket.is_open ()) {
@@ -156,7 +157,7 @@ Socket::write (uint8_t const * data, int size)
        } while (ec == boost::asio::error::would_block);
 
        if (ec) {
-               throw NetworkError (String::compose (_("error during async_write (%1)"), ec.value ()));
+               throw NetworkError(String::compose(_("error during async_write (%1)"), error_details(ec)));
        }
 
        if (_write_digester) {
@@ -197,7 +198,7 @@ Socket::read (uint8_t* data, int size)
        } while (ec == boost::asio::error::would_block);
 
        if (ec) {
-               throw NetworkError (String::compose (_("error during async_read (%1)"), ec.value ()));
+               throw NetworkError(String::compose(_("error during async_read (%1)"), error_details(ec)));
        }
 
        if (_read_digester) {