|
@@ -13,13 +13,27 @@
|
|
|
// PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
#include <string>
|
|
|
-
|
|
|
+#include <sstream>
|
|
|
#include <exceptions/exceptions.h>
|
|
|
|
|
|
using isc::Exception;
|
|
|
|
|
|
namespace isc {
|
|
|
|
|
|
+Exception::Exception(const char* file, size_t line, const char* what)
|
|
|
+: file_(file), line_(line), what_(what) {
|
|
|
+ std::stringstream location;
|
|
|
+ location << what_ << "[" << file_ << ":" << line_ << "]";
|
|
|
+ verbose_what_ = location.str();
|
|
|
+}
|
|
|
+
|
|
|
+Exception::Exception(const char* file, size_t line, const std::string& what)
|
|
|
+ : file_(file), line_(line), what_(what) {
|
|
|
+ std::stringstream location;
|
|
|
+ location << what_ << "[" << file_ << ":" << line_ << "]";
|
|
|
+ verbose_what_ = location.str();
|
|
|
+}
|
|
|
+
|
|
|
const char*
|
|
|
Exception::what() const throw() {
|
|
|
return (what(false));
|
|
@@ -28,25 +42,20 @@ Exception::what() const throw() {
|
|
|
const char*
|
|
|
Exception::what(bool verbose) const throw() {
|
|
|
|
|
|
- const char* whatstr = "isc::Exception";
|
|
|
-
|
|
|
- // XXX: Even though it's very unlikely that c_str() throws an exception,
|
|
|
+ // Even though it's very unlikely that c_str() throws an exception,
|
|
|
// it's still not 100% guaranteed. To meet the exception specification
|
|
|
// of this function, we catch any unexpected exception and fall back to
|
|
|
// the pre-defined constant.
|
|
|
try {
|
|
|
if (verbose) {
|
|
|
- static std::stringstream location;
|
|
|
- location.str("");
|
|
|
- location << what_ << "[" << file_ << ":" << line_ << "]";
|
|
|
- whatstr = location.str().c_str();
|
|
|
+ return (verbose_what_.c_str());
|
|
|
} else {
|
|
|
- whatstr = what_.c_str();
|
|
|
+ return (what_.c_str());
|
|
|
}
|
|
|
} catch (...) {
|
|
|
// no exception handling is necessary. just have to catch exceptions.
|
|
|
}
|
|
|
- return (whatstr);
|
|
|
+ return ("isc::Exception");
|
|
|
}
|
|
|
|
|
|
}
|