Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72482 - sandbox/tools/auto_index/src
From: john_at_[hidden]
Date: 2011-06-08 07:04:22


Author: johnmaddock
Date: 2011-06-08 07:04:21 EDT (Wed, 08 Jun 2011)
New Revision: 72482
URL: http://svn.boost.org/trac/boost/changeset/72482

Log:
Minor refactoring of error handling code.
Text files modified:
   sandbox/tools/auto_index/src/index_generator.cpp | 33 +++++++++++++++++++--------------
   1 files changed, 19 insertions(+), 14 deletions(-)

Modified: sandbox/tools/auto_index/src/index_generator.cpp
==============================================================================
--- sandbox/tools/auto_index/src/index_generator.cpp (original)
+++ sandbox/tools/auto_index/src/index_generator.cpp 2011-06-08 07:04:21 EDT (Wed, 08 Jun 2011)
@@ -18,6 +18,11 @@
    ++index_id_count;
    return s.str();
 }
+
+void raise_invalid_xml(const std::string& parent, const std::string& child)
+{
+ throw std::runtime_error("Error: element " + child + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\".");
+}
 //
 // Validate that the container for the Index is in a valid place:
 //
@@ -31,14 +36,14 @@
          && (parent != "partintro")
          && (parent != "preface")
          && (parent != "section"))
- throw std::runtime_error("Error: element " + container + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\".");
+ raise_invalid_xml(parent, container);
    }
    else if(container == "appendix")
    {
       if((parent != "article")
          && (parent != "book")
          && (parent != "part"))
- throw std::runtime_error("Error: element " + container + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\".");
+ raise_invalid_xml(parent, container);
    }
    else if(container == "index")
    {
@@ -55,38 +60,38 @@
          && (parent != "sect5")
          && (parent != "section")
          )
- throw std::runtime_error("Error: element " + container + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\".");
+ raise_invalid_xml(parent, container);
    }
    else if((container == "article") || (container == "chapter") || (container == "reference"))
    {
       if((parent != "book")
          && (parent != "part"))
- throw std::runtime_error("Error: element " + container + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\".");
+ raise_invalid_xml(parent, container);
    }
    else if(container == "part")
    {
       if(parent != "book")
- throw std::runtime_error("Error: element " + container + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\".");
+ raise_invalid_xml(parent, container);
    }
    else if(container == "refsect1")
    {
       if(parent != "refentry")
- throw std::runtime_error("Error: element " + container + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\".");
+ raise_invalid_xml(parent, container);
    }
    else if(container == "refsect2")
    {
       if(parent != "refsect1")
- throw std::runtime_error("Error: element " + container + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\".");
+ raise_invalid_xml(parent, container);
    }
    else if(container == "refsect3")
    {
       if(parent != "refsect2")
- throw std::runtime_error("Error: element " + container + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\".");
+ raise_invalid_xml(parent, container);
    }
    else if(container == "refsection")
    {
       if((parent != "refsection") && (parent != "refentry"))
- throw std::runtime_error("Error: element " + container + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\".");
+ raise_invalid_xml(parent, container);
    }
    else if(container == "sect1")
    {
@@ -96,27 +101,27 @@
          && (parent != "partintro")
          && (parent != "preface")
          )
- throw std::runtime_error("Error: element " + container + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\".");
+ raise_invalid_xml(parent, container);
    }
    else if(container == "sect2")
    {
       if(parent != "sect1")
- throw std::runtime_error("Error: element " + container + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\".");
+ raise_invalid_xml(parent, container);
    }
    else if(container == "sect3")
    {
       if(parent != "sect2")
- throw std::runtime_error("Error: element " + container + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\".");
+ raise_invalid_xml(parent, container);
    }
    else if(container == "sect4")
    {
       if(parent != "sect3")
- throw std::runtime_error("Error: element " + container + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\".");
+ raise_invalid_xml(parent, container);
    }
    else if(container == "sect5")
    {
       if(parent != "sect4")
- throw std::runtime_error("Error: element " + container + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\".");
+ raise_invalid_xml(parent, container);
    }
    else
    {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk