diff options
author | randomdan <randomdan@localhost> | 2011-07-28 23:58:39 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2011-07-28 23:58:39 +0000 |
commit | 6564f03c1df962a8fb5fd08f5781e2a8d2121dcd (patch) | |
tree | e9aafb77e7094486af21acfb69ba7a6a0d132d05 /project2/structExceptHandling.cpp | |
parent | Plugable variable doobries (diff) | |
download | project2-6564f03c1df962a8fb5fd08f5781e2a8d2121dcd.tar.bz2 project2-6564f03c1df962a8fb5fd08f5781e2a8d2121dcd.tar.xz project2-6564f03c1df962a8fb5fd08f5781e2a8d2121dcd.zip |
Half decent error handling in scripts with project2:handler[try/catch/finally]
Component to validate a date string
Merge some code (fixes sqlmerge missing attachments to ifs)
Minor fixes
New changelog importer in GB
Diffstat (limited to 'project2/structExceptHandling.cpp')
-rw-r--r-- | project2/structExceptHandling.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/project2/structExceptHandling.cpp b/project2/structExceptHandling.cpp new file mode 100644 index 0000000..f87b870 --- /dev/null +++ b/project2/structExceptHandling.cpp @@ -0,0 +1,53 @@ +#include "structExceptHandling.h" +#include "xmlObjectLoader.h" +#include "xmlStorage.h" +#include <boost/foreach.hpp> + +DECLARE_LOADER("handler", StructuredExceptionHandler); + +static void +loadHelper(const char * name, const xmlpp::Element * root, ANONORDEREDSTORAGEOF(NoOutputExecute) * noes) +{ + LoaderBase loader(true); + loader.supportedStorers.insert(Storer::into(noes)); + BOOST_FOREACH(const xmlpp::Node * node, root->find(name)) { + const xmlpp::Element * elem = dynamic_cast<const xmlpp::Element *>(node); + if (elem) { + loader.collectAll(elem, true, ErrorOnUnsupported); + } + } +} + +StructuredExceptionHandler::StructuredExceptionHandler(const xmlpp::Element * e) : + SourceObject(e), + IHaveSubTasks(e) +{ + loadHelper("try", e, &normal); + loadHelper("catch", e, &catches); + loadHelper("finally", e, &finallies); +} + +void +StructuredExceptionHandler::loadComplete(const CommonObjects * co) +{ + IHaveSubTasks::loadComplete(co); +} + +void +StructuredExceptionHandler::execute() const +{ + try { + run(normal); + } + catch (...) { + try { + run(catches); + } + catch (...) { + } + run(finallies); + throw; + } + run(finallies); +} + |