[glibmm] tls_client test: Catch an exception
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] tls_client test: Catch an exception
- Date: Thu, 27 Jun 2013 07:47:46 +0000 (UTC)
commit 110ac620ad7bfa248e4bde54758846847a0fe9f5
Author: Murray Cumming <murrayc murrayc com>
Date: Tue May 21 15:17:25 2013 +0200
tls_client test: Catch an exception
* giomm_tls_client/main.c: Catch an exception because that is what
actually happens when there is no internet connection.
It still fails in that case, however.
tests/giomm_tls_client/main.cc | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/tests/giomm_tls_client/main.cc b/tests/giomm_tls_client/main.cc
index a6f43d4..6518112 100644
--- a/tests/giomm_tls_client/main.cc
+++ b/tests/giomm_tls_client/main.cc
@@ -28,12 +28,27 @@ int main(int, char**)
const Glib::ustring test_host = "www.google.com";
- std::vector< Glib::RefPtr<Gio::InetAddress> > inet_addresses =
- Gio::Resolver::get_default()->lookup_by_name(test_host);
+ std::vector< Glib::RefPtr<Gio::InetAddress> > inet_addresses;
+ try
+ {
+ inet_addresses =
+ Gio::Resolver::get_default()->lookup_by_name(test_host);
+ }
+ catch(const Gio::ResolverError& ex)
+ {
+ //This happens if it could not resolve the name,
+ //for instance if we are not connected to the internet.
+ //TODO: Change this test so it can do something useful and succeed even
+ //if the testing computer is not connected to the internet.
+ std::cerr << "Gio::Resolver::lookup_by_name() threw exception: " << ex.what() << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ //Actually, it would throw an exception instead of reaching here with 0 addresses resolved.
if(inet_addresses.size() == 0)
{
- std::cout << "Could not resolve test host '" << test_host << "'." <<
+ std::cerr << "Could not resolve test host '" << test_host << "'." <<
std::endl;
return EXIT_FAILURE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]