Browse Source

made JSONError a subclass of isc::Exception instead of std:runtime_error
removed the now obsolete DecodeError


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac172@2116 e5f2f494-b856-4b98-b285-d166d9295462

Jelte Jansen 15 years ago
parent
commit
90c2af0b37
2 changed files with 10 additions and 22 deletions
  1. 7 7
      src/lib/cc/data.cc
  2. 3 15
      src/lib/cc/data.h

+ 7 - 7
src/lib/cc/data.cc

@@ -208,9 +208,9 @@ throwJSONError(const std::string& error, const std::string& file, int line = 0,
     if (line != 0 || pos != 0) {
         std::stringstream ss;
         ss << error << " in " + file + ":" << line << ":" << pos;
-        throw JSONError(ss.str());
+        isc_throw(JSONError, ss.str());
     } else {
-        throw JSONError(error);
+        isc_throw(JSONError, error);
     }
 }
 }
@@ -389,7 +389,7 @@ from_stringstream_number(std::istream &in, int &pos) {
     in >> i;
     pos += count_chars_i(i);
     if (in.fail()) {
-        throw JSONError("Bad integer or overflow");
+        isc_throw(JSONError, "Bad integer or overflow");
     }
     if (in.peek() == '.') {
         is_double = true;
@@ -397,7 +397,7 @@ from_stringstream_number(std::istream &in, int &pos) {
         pos++;
         in >> d_i;
         if (in.fail()) {
-            throw JSONError("Bad real or overflow");
+            isc_throw(JSONError, "Bad real or overflow");
         }
         d = i + (double)d_i / 10;
         pos += count_chars_i(d_i);
@@ -409,12 +409,12 @@ from_stringstream_number(std::istream &in, int &pos) {
         pos++;
         in >> e;
         if (in.fail()) {
-            throw JSONError("Bad exponent or overflow");
+            isc_throw(JSONError, "Bad exponent or overflow");
         }
         pos += count_chars_i(e);
         p = pow(10, e);
         if (p == HUGE_VAL) {
-            throw JSONError("Bad exponent or overflow");
+            isc_throw(JSONError, "Bad exponent or overflow");
         }
         if (is_double) {
             d = d * p;
@@ -601,7 +601,7 @@ Element::fromJSON(std::istream &in, const std::string& file, int& line, int& pos
     if (el_read) {
         return element;
     } else {
-        throw JSONError("nothing read");
+        isc_throw(JSONError, "nothing read");
     }
 }
 

+ 3 - 15
src/lib/cc/data.h

@@ -48,22 +48,10 @@ public:
 // i'd like to use Exception here but we need one that is derived from
 // runtime_error (as this one is directly based on external data, and
 // i want to add some values to any static data string that is provided)
-class JSONError : public std::runtime_error {
+class JSONError : public isc::Exception {
 public:
-    JSONError(const std::string &err) : std::runtime_error(err) {};
-};
-
-///
-/// \brief A standard Data module exception that is thrown if an error
-/// is found when decoding an Element from wire format
-///
-class DecodeError : public std::exception {
-public:
-    DecodeError(std::string m = "Wire-format data is invalid") : msg(m) {}
-    ~DecodeError() throw() {}
-    const char* what() const throw() { return msg.c_str(); }
-private:
-    std::string msg;
+    JSONError(const char* file, size_t line, const char* what) :
+        isc::Exception(file, line, what) {}
 };
 
 ///