From 272b34c1a4639cd0f909bfb52d30339c93b0c42b Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Fri, 6 Jun 2014 22:00:39 +0200 Subject: 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 --- src/support/error/error_capacitor.cc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'src/support/error/error_capacitor.cc') diff --git a/src/support/error/error_capacitor.cc b/src/support/error/error_capacitor.cc index 58cfb81..cc7dd01 100644 --- a/src/support/error/error_capacitor.cc +++ b/src/support/error/error_capacitor.cc @@ -3,14 +3,8 @@ namespace InputXSLT { ErrorCapacitor::ErrorCapacitor(ErrorMultiplexer* multiplexer): - multiplexer_(multiplexer), - error_cache_(new error_cache()) { - this->multiplexer_->connectReceiver(this); -} - -ErrorCapacitor::~ErrorCapacitor() { - this->multiplexer_->disconnectReceiver(this); -} + ErrorMultiplexer::receiver(multiplexer), + error_cache_(new error_cache()) { } void ErrorCapacitor::discharge() { if ( !this->error_cache_->empty() ) { @@ -19,10 +13,10 @@ void ErrorCapacitor::discharge() { } void ErrorCapacitor::receive( - const ErrorMultiplexer::ErrorType type, + const ErrorMultiplexer::error_type type, const std::string& message ) { - if ( type == ErrorMultiplexer::ErrorType::Error ) { + if ( type == ErrorMultiplexer::error_type::error ) { this->error_cache_->emplace_back(message); } } @@ -30,8 +24,8 @@ void ErrorCapacitor::receive( ErrorCapacitor::exception::exception(error_cache_ptr ptr): error_cache_(std::move(ptr)) { } -auto ErrorCapacitor::exception::getCachedErrors() const -> const error_cache* { - return this->error_cache_.get(); +auto ErrorCapacitor::exception::operator*() const -> const error_cache& { + return *(this->error_cache_.get()); } } -- cgit v1.2.3