From 5859cb6af4a5136a96971c47e41e6195007ef944 Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Wed, 28 May 2014 21:51:39 +0200 Subject: 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 --- src/support/error_handler.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/support/error_handler.cc (limited to 'src/support/error_handler.cc') 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 + +#include + +#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(e.getMessage()) + << std::endl; +} + +void ErrorHandler::error(const xercesc::SAXParseException& e) { + std::cerr << "Error in " + << "'" + << this->transformation_path_ + << "': " + << *XercesStringGuard(e.getMessage()) + << std::endl; +} + +void ErrorHandler::fatalError(const xercesc::SAXParseException& e) { + std::cerr << "Fatal error in " + << "'" + << this->transformation_path_ + << "': " + << *XercesStringGuard(e.getMessage()) + << std::endl; +} + +void ErrorHandler::resetErrors() { } + +} -- cgit v1.2.3