diff --git a/src/message_handler.cpp b/src/message_handler.cpp index 2e44bd4..122a88c 100644 --- a/src/message_handler.cpp +++ b/src/message_handler.cpp @@ -17,16 +17,20 @@ TcpService::getInstance().start(Config::TCP_SERVICE_LOCALE_PORT); io.run(); } catch (const boost::wrapexcept &e) { - std::cerr << "[WARN] Boost exception: " << e.what() << std::endl; + std::cerr << "MessageHandler [TcpService]" << e.what() << std::endl; } }); // 启动TCP客户端 std::thread client_thread([] { - boost::asio::io_service io; - TcpClient client; - client.connect(Config::REMOTE_SERVICE_IP, Config::TCP_SERVICE_REMOTE_PORT); - io.run(); + try { + boost::asio::io_service io; + TcpClient client; + client.connect(Config::REMOTE_SERVICE_IP, Config::TCP_SERVICE_REMOTE_PORT); + io.run(); + } catch (const boost::wrapexcept &e) { + std::cerr << "MessageHandler [TcpClient]" << e.what() << std::endl; + } }); //启动甲烷数据查询串口线程 @@ -38,7 +42,7 @@ sp.read_from_port(); io.run(); } catch (std::exception &e) { - std::cerr << e.what() << std::endl; + std::cerr << "MessageHandler [MethaneSerialPort]" << e.what() << std::endl; } }); diff --git a/src/message_handler.cpp b/src/message_handler.cpp index 2e44bd4..122a88c 100644 --- a/src/message_handler.cpp +++ b/src/message_handler.cpp @@ -17,16 +17,20 @@ TcpService::getInstance().start(Config::TCP_SERVICE_LOCALE_PORT); io.run(); } catch (const boost::wrapexcept &e) { - std::cerr << "[WARN] Boost exception: " << e.what() << std::endl; + std::cerr << "MessageHandler [TcpService]" << e.what() << std::endl; } }); // 启动TCP客户端 std::thread client_thread([] { - boost::asio::io_service io; - TcpClient client; - client.connect(Config::REMOTE_SERVICE_IP, Config::TCP_SERVICE_REMOTE_PORT); - io.run(); + try { + boost::asio::io_service io; + TcpClient client; + client.connect(Config::REMOTE_SERVICE_IP, Config::TCP_SERVICE_REMOTE_PORT); + io.run(); + } catch (const boost::wrapexcept &e) { + std::cerr << "MessageHandler [TcpClient]" << e.what() << std::endl; + } }); //启动甲烷数据查询串口线程 @@ -38,7 +42,7 @@ sp.read_from_port(); io.run(); } catch (std::exception &e) { - std::cerr << e.what() << std::endl; + std::cerr << "MessageHandler [MethaneSerialPort]" << e.what() << std::endl; } }); diff --git a/src/slam_wrapper.cpp b/src/slam_wrapper.cpp index 8a2580a..2dade74 100644 --- a/src/slam_wrapper.cpp +++ b/src/slam_wrapper.cpp @@ -122,7 +122,7 @@ }); serial_port_thread.detach(); } catch (const boost::wrapexcept &e) { - std::cerr << "Boost exception: " << e.what() << std::endl; + std::cerr << "SlamWrapper [RoboticArmSerialPort]" << e.what() << std::endl; } // pub diff --git a/src/message_handler.cpp b/src/message_handler.cpp index 2e44bd4..122a88c 100644 --- a/src/message_handler.cpp +++ b/src/message_handler.cpp @@ -17,16 +17,20 @@ TcpService::getInstance().start(Config::TCP_SERVICE_LOCALE_PORT); io.run(); } catch (const boost::wrapexcept &e) { - std::cerr << "[WARN] Boost exception: " << e.what() << std::endl; + std::cerr << "MessageHandler [TcpService]" << e.what() << std::endl; } }); // 启动TCP客户端 std::thread client_thread([] { - boost::asio::io_service io; - TcpClient client; - client.connect(Config::REMOTE_SERVICE_IP, Config::TCP_SERVICE_REMOTE_PORT); - io.run(); + try { + boost::asio::io_service io; + TcpClient client; + client.connect(Config::REMOTE_SERVICE_IP, Config::TCP_SERVICE_REMOTE_PORT); + io.run(); + } catch (const boost::wrapexcept &e) { + std::cerr << "MessageHandler [TcpClient]" << e.what() << std::endl; + } }); //启动甲烷数据查询串口线程 @@ -38,7 +42,7 @@ sp.read_from_port(); io.run(); } catch (std::exception &e) { - std::cerr << e.what() << std::endl; + std::cerr << "MessageHandler [MethaneSerialPort]" << e.what() << std::endl; } }); diff --git a/src/slam_wrapper.cpp b/src/slam_wrapper.cpp index 8a2580a..2dade74 100644 --- a/src/slam_wrapper.cpp +++ b/src/slam_wrapper.cpp @@ -122,7 +122,7 @@ }); serial_port_thread.detach(); } catch (const boost::wrapexcept &e) { - std::cerr << "Boost exception: " << e.what() << std::endl; + std::cerr << "SlamWrapper [RoboticArmSerialPort]" << e.what() << std::endl; } // pub diff --git a/src/tcp_service.cpp b/src/tcp_service.cpp index 490f703..6b30262 100644 --- a/src/tcp_service.cpp +++ b/src/tcp_service.cpp @@ -107,7 +107,7 @@ client_thread.join(); } } catch (const std::exception &e) { - std::cerr << "[WARN] TcpService start " << e.what() << std::endl; + std::cerr << "[TcpService] start " << e.what() << std::endl; } }