aboutsummaryrefslogtreecommitdiff
path: root/src/support/error/error_multiplexer.cc
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-06-06 22:00:39 +0200
committerAdrian Kummerländer2014-06-06 22:00:39 +0200
commit272b34c1a4639cd0f909bfb52d30339c93b0c42b (patch)
treed3bed13ddf28e86f8de319222daf535305082431 /src/support/error/error_multiplexer.cc
parent78bb3387b15d15d766fb5d17a99612f0480f2bee (diff)
downloadInputXSLT-272b34c1a4639cd0f909bfb52d30339c93b0c42b.tar
InputXSLT-272b34c1a4639cd0f909bfb52d30339c93b0c42b.tar.gz
InputXSLT-272b34c1a4639cd0f909bfb52d30339c93b0c42b.tar.bz2
InputXSLT-272b34c1a4639cd0f909bfb52d30339c93b0c42b.tar.lz
InputXSLT-272b34c1a4639cd0f909bfb52d30339c93b0c42b.tar.xz
InputXSLT-272b34c1a4639cd0f909bfb52d30339c93b0c42b.tar.zst
InputXSLT-272b34c1a4639cd0f909bfb52d30339c93b0c42b.zip
Implemented WarningCapacitor as a counterpart to ErrorCapacitor
* in difference to ErrorCapacitor this class doesn't throw an exception on "discharge" but returns the gathered warnings * adapted FunctionTransform and frontend error handling to include warnings * added static "try_create" method to TransformationFacade ** wraps construction error handling ** custom logic may be embedded using the std::function argument *** this was implemented to prevent unneccessary code duplication for handling both construction and generation errors * adapted FunctionTransform to return warning as "warning" nodes in the result tree ** added functional lambda expression factory method "handleErrors" *** returns a error handling lambda expression for a given ResultNodeFacade * implemented WarningGuard class in frontend executable ** guarantees warnings to be printed to std::cerr independent of any exceptions
Diffstat (limited to 'src/support/error/error_multiplexer.cc')
-rw-r--r--src/support/error/error_multiplexer.cc29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/support/error/error_multiplexer.cc b/src/support/error/error_multiplexer.cc
index f5d4e0f..bbf0e71 100644
--- a/src/support/error/error_multiplexer.cc
+++ b/src/support/error/error_multiplexer.cc
@@ -27,15 +27,15 @@ inline std::string getMessage(const xercesc::SAXParseException& exception) {
);
}
-inline ErrorMultiplexer::ErrorType toErrorType(
+inline ErrorMultiplexer::error_type toErrorType(
const xalan::ProblemListenerBase::eClassification classification) {
switch ( classification ) {
case xalan::ProblemListenerBase::eClassification::eMessage ||
xalan::ProblemListenerBase::eClassification::eWarning: {
- return ErrorMultiplexer::ErrorType::Warning;
+ return ErrorMultiplexer::error_type::warning;
}
default: {
- return ErrorMultiplexer::ErrorType::Error;
+ return ErrorMultiplexer::error_type::error;
}
}
}
@@ -56,11 +56,11 @@ ErrorMultiplexer::~ErrorMultiplexer() {
this->transformer_->setProblemListener(nullptr);
}
-void ErrorMultiplexer::connectReceiver(Receiver* receiver) {
+void ErrorMultiplexer::connectReceiver(receiver* receiver) {
this->receivers_.push_back(receiver);
}
-void ErrorMultiplexer::disconnectReceiver(Receiver* receiver) {
+void ErrorMultiplexer::disconnectReceiver(receiver* receiver) {
this->receivers_.erase(
std::remove(
this->receivers_.begin(),
@@ -72,21 +72,21 @@ void ErrorMultiplexer::disconnectReceiver(Receiver* receiver) {
void ErrorMultiplexer::warning(const xercesc::SAXParseException& exception) {
this->multiplex(
- ErrorType::Warning,
+ error_type::warning,
"Warning: " + getMessage(exception)
);
}
void ErrorMultiplexer::error(const xercesc::SAXParseException& exception) {
this->multiplex(
- ErrorType::Error,
+ error_type::error,
"Error: " + getMessage(exception)
);
}
void ErrorMultiplexer::fatalError(const xercesc::SAXParseException& exception) {
this->multiplex(
- ErrorType::Error,
+ error_type::error,
"Fatal error: " + getMessage(exception)
);
}
@@ -155,16 +155,25 @@ void ErrorMultiplexer::problem(
void ErrorMultiplexer::setPrintWriter(xalan::PrintWriter*) { }
void ErrorMultiplexer::multiplex(
- const ErrorType type,
+ const error_type type,
const std::string& message
) {
std::for_each(
this->receivers_.begin(),
this->receivers_.end(),
- [&type, &message](Receiver* const receiver) -> void {
+ [&type, &message](receiver* const receiver) -> void {
receiver->receive(type, message);
}
);
}
+ErrorMultiplexer::receiver::receiver(ErrorMultiplexer* multiplexer):
+ multiplexer_(multiplexer) {
+ this->multiplexer_->connectReceiver(this);
+}
+
+ErrorMultiplexer::receiver::~receiver() {
+ this->multiplexer_->disconnectReceiver(this);
+}
+
}