From: Mukund Sivaraman Date: Thu, 30 Jan 2014 05:47:43 +0000 (+0530) Subject: [2518] Introduce DNSTextError and remove generic catch for isc::Exception from the... X-Git-Tag: bind10-1.2.0beta1-release~48^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ab8ff1eda4c0daaeaf06614651ecea31a38339ab;p=thirdparty%2Fkea.git [2518] Introduce DNSTextError and remove generic catch for isc::Exception from the MasterLoader --- diff --git a/src/lib/dns/exceptions.h b/src/lib/dns/exceptions.h index 34413aa4a1..21030b49c2 100644 --- a/src/lib/dns/exceptions.h +++ b/src/lib/dns/exceptions.h @@ -36,13 +36,22 @@ public: isc::Exception(file, line, what) {} }; +/// +/// \brief Base class for all sorts of text parse errors. +/// +class DNSTextError : public isc::dns::Exception { +public: + DNSTextError(const char* file, size_t line, const char* what) : + isc::dns::Exception(file, line, what) {} +}; + /// /// \brief Base class for name parser exceptions. /// -class NameParserException : public isc::dns::Exception { +class NameParserException : public DNSTextError { public: NameParserException(const char* file, size_t line, const char* what) : - isc::dns::Exception(file, line, what) {} + DNSTextError(file, line, what) {} }; class DNSProtocolError : public isc::dns::Exception { diff --git a/src/lib/dns/master_loader.cc b/src/lib/dns/master_loader.cc index 6b6e091489..095a2724d3 100644 --- a/src/lib/dns/master_loader.cc +++ b/src/lib/dns/master_loader.cc @@ -576,15 +576,19 @@ MasterLoader::MasterLoaderImpl::loadIncremental(size_t count_limit) { isc_throw(MasterLoaderError, "Invalid RR data"); } } - } catch (const MasterLoaderError&) { - // This is a hack. We exclude the MasterLoaderError from the - // below case. Once we restrict the below to some smaller - // exception, we should remove this. - throw; - } catch (const isc::Exception& e) { - // TODO: Once we do #2518, catch only the DNSTextError here, - // not isc::Exception. The rest should be just simply - // propagated. + } catch (const isc::dns::DNSTextError& e) { + reportError(lexer_.getSourceName(), lexer_.getSourceLine(), + e.what()); + eatUntilEOL(false); + } catch (const MasterLexer::ReadError& e) { + reportError(lexer_.getSourceName(), lexer_.getSourceLine(), + e.what()); + eatUntilEOL(false); + } catch (const MasterLexer::LexerError& e) { + reportError(lexer_.getSourceName(), lexer_.getSourceLine(), + e.what()); + eatUntilEOL(false); + } catch (const InternalException& e) { reportError(lexer_.getSourceName(), lexer_.getSourceLine(), e.what()); eatUntilEOL(false); diff --git a/src/lib/dns/rdata.h b/src/lib/dns/rdata.h index a1115fd2a3..58603bede3 100644 --- a/src/lib/dns/rdata.h +++ b/src/lib/dns/rdata.h @@ -42,20 +42,20 @@ namespace rdata { /// \brief A standard DNS module exception that is thrown if RDATA parser /// encounters an invalid or inconsistent data length. /// -class InvalidRdataLength : public isc::dns::Exception { +class InvalidRdataLength : public DNSTextError { public: InvalidRdataLength(const char* file, size_t line, const char* what) : - isc::dns::Exception(file, line, what) {} + DNSTextError(file, line, what) {} }; /// /// \brief A standard DNS module exception that is thrown if RDATA parser /// fails to recognize a given textual representation. /// -class InvalidRdataText : public isc::dns::Exception { +class InvalidRdataText : public DNSTextError { public: InvalidRdataText(const char* file, size_t line, const char* what) : - isc::dns::Exception(file, line, what) {} + DNSTextError(file, line, what) {} }; /// @@ -63,10 +63,10 @@ public: /// encounters a character-string (as defined in RFC1035) exceeding /// the maximum allowable length (\c MAX_CHARSTRING_LEN). /// -class CharStringTooLong : public isc::dns::Exception { +class CharStringTooLong : public DNSTextError { public: CharStringTooLong(const char* file, size_t line, const char* what) : - isc::dns::Exception(file, line, what) {} + DNSTextError(file, line, what) {} }; // Forward declaration to define RdataPtr. diff --git a/src/lib/dns/rrclass-placeholder.h b/src/lib/dns/rrclass-placeholder.h index 56d94741b5..709057e818 100644 --- a/src/lib/dns/rrclass-placeholder.h +++ b/src/lib/dns/rrclass-placeholder.h @@ -39,10 +39,10 @@ class AbstractMessageRenderer; /// \brief A standard DNS module exception that is thrown if an RRClass object /// is being constructed from an unrecognized string. /// -class InvalidRRClass : public isc::dns::Exception { +class InvalidRRClass : public DNSTextError { public: InvalidRRClass(const char* file, size_t line, const char* what) : - isc::dns::Exception(file, line, what) {} + DNSTextError(file, line, what) {} }; /// diff --git a/src/lib/dns/rrttl.h b/src/lib/dns/rrttl.h index 7804234115..ffa3467970 100644 --- a/src/lib/dns/rrttl.h +++ b/src/lib/dns/rrttl.h @@ -36,10 +36,10 @@ class AbstractMessageRenderer; /// \brief A standard DNS module exception that is thrown if an RRTTL object /// is being constructed from an unrecognized string. /// -class InvalidRRTTL : public isc::dns::Exception { +class InvalidRRTTL : public DNSTextError { public: InvalidRRTTL(const char* file, size_t line, const char* what) : - isc::dns::Exception(file, line, what) {} + DNSTextError(file, line, what) {} }; /// diff --git a/src/lib/dns/rrtype-placeholder.h b/src/lib/dns/rrtype-placeholder.h index 08ab287f33..46167e45dc 100644 --- a/src/lib/dns/rrtype-placeholder.h +++ b/src/lib/dns/rrtype-placeholder.h @@ -42,10 +42,10 @@ class AbstractMessageRenderer; /// \brief A standard DNS module exception that is thrown if an RRType object /// is being constructed from an unrecognized string. /// -class InvalidRRType : public isc::dns::Exception { +class InvalidRRType : public DNSTextError { public: InvalidRRType(const char* file, size_t line, const char* what) : - isc::dns::Exception(file, line, what) {} + DNSTextError(file, line, what) {} }; ///