diff options
author | Adrian Kummerländer | 2014-05-28 21:51:39 +0200 |
---|---|---|
committer | Adrian Kummerländer | 2014-05-28 21:51:39 +0200 |
commit | 5859cb6af4a5136a96971c47e41e6195007ef944 (patch) | |
tree | 77431a85377b3b3742bcdb6c30526d957f9f61c1 /src/support | |
parent | 802d416040aa31d72defa7a9227cd31b0885bc60 (diff) | |
download | InputXSLT-5859cb6af4a5136a96971c47e41e6195007ef944.tar InputXSLT-5859cb6af4a5136a96971c47e41e6195007ef944.tar.gz InputXSLT-5859cb6af4a5136a96971c47e41e6195007ef944.tar.bz2 InputXSLT-5859cb6af4a5136a96971c47e41e6195007ef944.tar.lz InputXSLT-5859cb6af4a5136a96971c47e41e6195007ef944.tar.xz InputXSLT-5859cb6af4a5136a96971c47e41e6195007ef944.tar.zst InputXSLT-5859cb6af4a5136a96971c47e41e6195007ef944.zip |
Implemented basic ErrorHandler
* InputXSLT::ErrorHandler is derived from xercesc::ErrorHandler and enables contextual printing of transformation errors
** currently this means that the error messages passed to std::cerr contain the full path of the offending transformation
* added input trimming to the external transform function
** calls to this function from inside a transformation may contain unnecessary whitespace characters which disrupt further processing
Diffstat (limited to 'src/support')
-rw-r--r-- | src/support/error_handler.cc | 43 | ||||
-rw-r--r-- | src/support/error_handler.h | 26 |
2 files changed, 69 insertions, 0 deletions
diff --git a/src/support/error_handler.cc b/src/support/error_handler.cc new file mode 100644 index 0000000..9a898a6 --- /dev/null +++ b/src/support/error_handler.cc @@ -0,0 +1,43 @@ +#include "error_handler.h" + +#include <xercesc/sax/SAXParseException.hpp> + +#include <iostream> + +#include "support/xerces_string_guard.h" + +namespace InputXSLT { + +ErrorHandler::ErrorHandler(const std::string& transformation): + transformation_path_(transformation) { } + +void ErrorHandler::warning(const xercesc::SAXParseException& e) { + std::cerr << "Warning in " + << "'" + << this->transformation_path_ + << "': " + << *XercesStringGuard<char>(e.getMessage()) + << std::endl; +} + +void ErrorHandler::error(const xercesc::SAXParseException& e) { + std::cerr << "Error in " + << "'" + << this->transformation_path_ + << "': " + << *XercesStringGuard<char>(e.getMessage()) + << std::endl; +} + +void ErrorHandler::fatalError(const xercesc::SAXParseException& e) { + std::cerr << "Fatal error in " + << "'" + << this->transformation_path_ + << "': " + << *XercesStringGuard<char>(e.getMessage()) + << std::endl; +} + +void ErrorHandler::resetErrors() { } + +} diff --git a/src/support/error_handler.h b/src/support/error_handler.h new file mode 100644 index 0000000..7835292 --- /dev/null +++ b/src/support/error_handler.h @@ -0,0 +1,26 @@ +#ifndef INPUTXSLT_SRC_SUPPORT_ERROR_HANDLER_H_ +#define INPUTXSLT_SRC_SUPPORT_ERROR_HANDLER_H_ + +#include <xercesc/sax/ErrorHandler.hpp> + +#include <string> + +namespace InputXSLT { + +class ErrorHandler : public xercesc::ErrorHandler { + public: + ErrorHandler(const std::string&); + + virtual void warning(const xercesc::SAXParseException&); + virtual void error(const xercesc::SAXParseException&); + virtual void fatalError(const xercesc::SAXParseException&); + virtual void resetErrors(); + + private: + const std::string& transformation_path_; + +}; + +} + +#endif // INPUTXSLT_SRC_SUPPORT_ERROR_HANDLER_H_ |