Commit cba6db1c authored by Stephen Morris's avatar Stephen Morris
Browse files

[trac542] Remove typeid from exception caught message

On some compilers, use of typeid() requires that RTTI is explicitly
specified on the compiler command line.  For an isc::Exception message,
the file and line number will identify the exception.  For a message
output caused by std::exception, the what() should identify the exception.
parent d4a2c864
...@@ -20,6 +20,7 @@ run_unittests_LDADD = $(GTEST_LDADD) ...@@ -20,6 +20,7 @@ run_unittests_LDADD = $(GTEST_LDADD)
run_unittests_LDADD += $(top_builddir)/src/lib/util/io/libutil_io.la run_unittests_LDADD += $(top_builddir)/src/lib/util/io/libutil_io.la
run_unittests_LDADD += \ run_unittests_LDADD += \
$(top_builddir)/src/lib/util/unittests/libutil_unittests.la $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
endif endif
noinst_PROGRAMS = $(TESTS) noinst_PROGRAMS = $(TESTS)
...@@ -8,7 +8,7 @@ libutil_unittests_la_SOURCES += run_all.h run_all.cc ...@@ -8,7 +8,7 @@ libutil_unittests_la_SOURCES += run_all.h run_all.cc
libutil_unittests_la_SOURCES += testdata.h testdata.cc libutil_unittests_la_SOURCES += testdata.h testdata.cc
libutil_unittests_la_SOURCES += textdata.h libutil_unittests_la_SOURCES += textdata.h
libutil_unittests_ls_LDADD = $(top_builddir)/src/lib/util/io/libutil_io.la libutil_unittests_la_LIBADD = $(top_builddir)/src/lib/util/libutil.la
libutil_unittests_ls_LDADD += $(top_builddir)/src/lib/util/libutil.la libutil_unittests_la_LIBADD = $(top_builddir)/src/lib/exceptions/libexceptions.la
CLEANFILES = *.gcno *.gcda CLEANFILES = *.gcno *.gcda
...@@ -33,16 +33,16 @@ run_all() { ...@@ -33,16 +33,16 @@ run_all() {
try { try {
ret = RUN_ALL_TESTS(); ret = RUN_ALL_TESTS();
} catch (const isc::Exception& ex) { } catch (const isc::Exception& ex) {
std::cerr << "*** isc::exception of class '" << typeid(ex).name() // Could output more information with typeid(), but there is no
<< "' was thrown:\n" // guarantee that all compilers will support it without an explicit
// flag on the command line.
std::cerr << "*** Exception derived from isc::exception thrown:\n"
<< " file: " << ex.getFile() << "\n" << " file: " << ex.getFile() << "\n"
<< " line: " << ex.getLine() << "\n" << " line: " << ex.getLine() << "\n"
<< " what: " << ex.what() << std::endl; << " what: " << ex.what() << std::endl;
throw; throw;
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
std::cerr << "*** std::exception of class '" std::cerr << "*** Exception derived from std::exception thrown:\n"
<< typeid(ex).name()
<< "' was thrown:\n"
<< " what: " << ex.what() << std::endl; << " what: " << ex.what() << std::endl;
throw; throw;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment