aboutsummaryrefslogtreecommitdiff
path: root/src/support
diff options
context:
space:
mode:
Diffstat (limited to 'src/support')
-rw-r--r--src/support/error_handler.cc63
-rw-r--r--src/support/error_handler.h13
-rw-r--r--src/support/include_entity_resolver.cc4
3 files changed, 54 insertions, 26 deletions
diff --git a/src/support/error_handler.cc b/src/support/error_handler.cc
index 9a898a6..db54225 100644
--- a/src/support/error_handler.cc
+++ b/src/support/error_handler.cc
@@ -6,38 +6,55 @@
#include "support/xerces_string_guard.h"
+namespace {
+
+inline std::string getMessage(const xercesc::SAXParseException& exception) {
+ return std::string(
+ *InputXSLT::XercesStringGuard<char>(exception.getMessage())
+ );
+}
+
+}
+
namespace InputXSLT {
-ErrorHandler::ErrorHandler(const std::string& transformation):
- transformation_path_(transformation) { }
+ErrorHandler::ErrorHandler():
+ error_cache_{} { }
+
+void ErrorHandler::warning(const xercesc::SAXParseException& exception) {
+ this->constructErrorCache();
-void ErrorHandler::warning(const xercesc::SAXParseException& e) {
- std::cerr << "Warning in "
- << "'"
- << this->transformation_path_
- << "': "
- << *XercesStringGuard<char>(e.getMessage())
- << std::endl;
+ this->error_cache_->emplace_back(
+ "Warning: " + getMessage(exception)
+ );
}
-void ErrorHandler::error(const xercesc::SAXParseException& e) {
- std::cerr << "Error in "
- << "'"
- << this->transformation_path_
- << "': "
- << *XercesStringGuard<char>(e.getMessage())
- << std::endl;
+void ErrorHandler::error(const xercesc::SAXParseException& exception) {
+ this->constructErrorCache();
+
+ this->error_cache_->emplace_back(
+ "Error: " + getMessage(exception)
+ );
}
-void ErrorHandler::fatalError(const xercesc::SAXParseException& e) {
- std::cerr << "Fatal error in "
- << "'"
- << this->transformation_path_
- << "': "
- << *XercesStringGuard<char>(e.getMessage())
- << std::endl;
+void ErrorHandler::fatalError(const xercesc::SAXParseException& exception) {
+ this->constructErrorCache();
+
+ this->error_cache_->emplace_back(
+ "Fatal error: " + getMessage(exception)
+ );
}
void ErrorHandler::resetErrors() { }
+auto ErrorHandler::getCachedErrors() -> error_cache_ptr {
+ return error_cache_ptr(this->error_cache_.release());
+}
+
+void ErrorHandler::constructErrorCache() {
+ if ( !this->error_cache_ ) {
+ this->error_cache_.reset(new error_cache());
+ }
+}
+
}
diff --git a/src/support/error_handler.h b/src/support/error_handler.h
index 7835292..77a46d8 100644
--- a/src/support/error_handler.h
+++ b/src/support/error_handler.h
@@ -3,21 +3,30 @@
#include <xercesc/sax/ErrorHandler.hpp>
+#include <memory>
+#include <vector>
#include <string>
namespace InputXSLT {
class ErrorHandler : public xercesc::ErrorHandler {
public:
- ErrorHandler(const std::string&);
+ typedef std::vector<std::string> error_cache;
+ typedef std::unique_ptr<error_cache> error_cache_ptr;
+
+ ErrorHandler();
virtual void warning(const xercesc::SAXParseException&);
virtual void error(const xercesc::SAXParseException&);
virtual void fatalError(const xercesc::SAXParseException&);
virtual void resetErrors();
+ error_cache_ptr getCachedErrors();
+
private:
- const std::string& transformation_path_;
+ error_cache_ptr error_cache_;
+
+ void constructErrorCache();
};
diff --git a/src/support/include_entity_resolver.cc b/src/support/include_entity_resolver.cc
index 948a61b..e63a3c4 100644
--- a/src/support/include_entity_resolver.cc
+++ b/src/support/include_entity_resolver.cc
@@ -48,7 +48,9 @@ xercesc::InputSource* IncludeEntityResolver::resolveEntity(
*XercesStringGuard<XMLCh>((*resolvedPath).string())
);
} else {
- return nullptr;
+ return new xercesc::LocalFileInputSource(
+ *XercesStringGuard<XMLCh>(*filePath)
+ );
}
} else {
return nullptr;