From 873221ec14dadc6791a146f760338a6b0b687198 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 21 Nov 2009 08:37:09 +0000 Subject: [PATCH] - Catch exception thrown by resolver.resolve() and display the error message on stderr --- src/reverseresolution.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/reverseresolution.h b/src/reverseresolution.h index ac59c20ad..5ee5b4273 100644 --- a/src/reverseresolution.h +++ b/src/reverseresolution.h @@ -70,10 +70,14 @@ signals: protected: void run() { - boost::asio::ip::tcp::resolver::iterator it = resolver.resolve(ip); - if(stopped) return; - boost::asio::ip::tcp::endpoint endpoint = *it; - emit ip_resolved(misc::toQString(endpoint.address().to_string()), misc::toQString((*it).host_name())); + try { + boost::asio::ip::tcp::resolver::iterator it = resolver.resolve(ip); + if(stopped) return; + boost::asio::ip::tcp::endpoint endpoint = *it; + emit ip_resolved(misc::toQString(endpoint.address().to_string()), misc::toQString((*it).host_name())); + } catch(std::exception &e) { + std::cerr << "Hostname resolution failed, reason: " << e.what() << std::endl; + } } };