Commit cba6db1c authored by Stephen Morris's avatar Stephen Morris

[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)
run_unittests_LDADD += $(top_builddir)/src/lib/util/io/libutil_io.la
run_unittests_LDADD += \
$(top_builddir)/src/lib/util/unittests/libutil_unittests.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
endif
noinst_PROGRAMS = $(TESTS)
......@@ -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 += textdata.h
libutil_unittests_ls_LDADD = $(top_builddir)/src/lib/util/io/libutil_io.la
libutil_unittests_ls_LDADD += $(top_builddir)/src/lib/util/libutil.la
libutil_unittests_la_LIBADD = $(top_builddir)/src/lib/util/libutil.la
libutil_unittests_la_LIBADD = $(top_builddir)/src/lib/exceptions/libexceptions.la
CLEANFILES = *.gcno *.gcda
......@@ -33,17 +33,17 @@ run_all() {
try {
ret = RUN_ALL_TESTS();
} catch (const isc::Exception& ex) {
std::cerr << "*** isc::exception of class '" << typeid(ex).name()
<< "' was thrown:\n"
<< " file: " << ex.getFile() << "\n"
<< " line: " << ex.getLine() << "\n"
<< " what: " << ex.what() << std::endl;
// Could output more information with typeid(), but there is no
// 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"
<< " line: " << ex.getLine() << "\n"
<< " what: " << ex.what() << std::endl;
throw;
} catch (const std::exception& ex) {
std::cerr << "*** std::exception of class '"
<< typeid(ex).name()
<< "' was thrown:\n"
<< " what: " << ex.what() << std::endl;
std::cerr << "*** Exception derived from std::exception thrown:\n"
<< " what: " << ex.what() << std::endl;
throw;
}
} else {
......
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