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

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,
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");
}
}
......
......@@ -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) {}
};
///
......
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