]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2518] Introduce DNSTextError and remove generic catch for isc::Exception from the...
authorMukund Sivaraman <muks@isc.org>
Thu, 30 Jan 2014 05:47:43 +0000 (11:17 +0530)
committerMukund Sivaraman <muks@isc.org>
Fri, 31 Jan 2014 07:00:09 +0000 (12:30 +0530)
src/lib/dns/exceptions.h
src/lib/dns/master_loader.cc
src/lib/dns/rdata.h
src/lib/dns/rrclass-placeholder.h
src/lib/dns/rrttl.h
src/lib/dns/rrtype-placeholder.h

index 34413aa4a1d0b7dc714598cf99a3b4ccd1abd1a5..21030b49c2f18c49516517ff84ef1a3ae93a1483 100644 (file)
@@ -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 {
index 6b6e09148901144cd640a5de8be06f45021c0470..095a2724d3dcdb7a9c6751fd5a27f7d48ad808b1 100644 (file)
@@ -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);
index a1115fd2a3370f58d801907813ab75cadcafb0a3..58603bede38ac4373190f2277b131ad3553956b9 100644 (file)
@@ -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.
index 56d94741b5f8865315de8c31ad2048c729a776c1..709057e8189bed1856e6f029c1240d15d725542d 100644 (file)
@@ -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) {}
 };
 
 ///
index 7804234115607f5811f85214f07cfdf98ce71ebc..ffa3467970ddc6f9df7ec072fecb1c283ae01314 100644 (file)
@@ -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) {}
 };
 
 ///
index 08ab287f3327e78c5bded5ef0463e95faca162f9..46167e45dc0de2088a69a81e7ba4e8eace9b88a8 100644 (file)
@@ -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) {}
 };
 
 ///