Commit 90c2af0b authored by Jelte Jansen's avatar Jelte Jansen
Browse files

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
parent 89dad444
...@@ -208,9 +208,9 @@ throwJSONError(const std::string& error, const std::string& file, int line = 0, ...@@ -208,9 +208,9 @@ throwJSONError(const std::string& error, const std::string& file, int line = 0,
if (line != 0 || pos != 0) { if (line != 0 || pos != 0) {
std::stringstream ss; std::stringstream ss;
ss << error << " in " + file + ":" << line << ":" << pos; ss << error << " in " + file + ":" << line << ":" << pos;
throw JSONError(ss.str()); isc_throw(JSONError, ss.str());
} else { } else {
throw JSONError(error); isc_throw(JSONError, error);
} }
} }
} }
...@@ -389,7 +389,7 @@ from_stringstream_number(std::istream &in, int &pos) { ...@@ -389,7 +389,7 @@ from_stringstream_number(std::istream &in, int &pos) {
in >> i; in >> i;
pos += count_chars_i(i); pos += count_chars_i(i);
if (in.fail()) { if (in.fail()) {
throw JSONError("Bad integer or overflow"); isc_throw(JSONError, "Bad integer or overflow");
} }
if (in.peek() == '.') { if (in.peek() == '.') {
is_double = true; is_double = true;
...@@ -397,7 +397,7 @@ from_stringstream_number(std::istream &in, int &pos) { ...@@ -397,7 +397,7 @@ from_stringstream_number(std::istream &in, int &pos) {
pos++; pos++;
in >> d_i; in >> d_i;
if (in.fail()) { if (in.fail()) {
throw JSONError("Bad real or overflow"); isc_throw(JSONError, "Bad real or overflow");
} }
d = i + (double)d_i / 10; d = i + (double)d_i / 10;
pos += count_chars_i(d_i); pos += count_chars_i(d_i);
...@@ -409,12 +409,12 @@ from_stringstream_number(std::istream &in, int &pos) { ...@@ -409,12 +409,12 @@ from_stringstream_number(std::istream &in, int &pos) {
pos++; pos++;
in >> e; in >> e;
if (in.fail()) { if (in.fail()) {
throw JSONError("Bad exponent or overflow"); isc_throw(JSONError, "Bad exponent or overflow");
} }
pos += count_chars_i(e); pos += count_chars_i(e);
p = pow(10, e); p = pow(10, e);
if (p == HUGE_VAL) { if (p == HUGE_VAL) {
throw JSONError("Bad exponent or overflow"); isc_throw(JSONError, "Bad exponent or overflow");
} }
if (is_double) { if (is_double) {
d = d * p; d = d * p;
...@@ -601,7 +601,7 @@ Element::fromJSON(std::istream &in, const std::string& file, int& line, int& pos ...@@ -601,7 +601,7 @@ Element::fromJSON(std::istream &in, const std::string& file, int& line, int& pos
if (el_read) { if (el_read) {
return element; return element;
} else { } else {
throw JSONError("nothing read"); isc_throw(JSONError, "nothing read");
} }
} }
......
...@@ -48,22 +48,10 @@ public: ...@@ -48,22 +48,10 @@ public:
// i'd like to use Exception here but we need one that is derived from // 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 // 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) // 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: public:
JSONError(const std::string &err) : std::runtime_error(err) {}; JSONError(const char* file, size_t line, const char* what) :
}; isc::Exception(file, line, what) {}
///
/// \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;
}; };
/// ///
......
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