diff options
author | Adrian Kummerländer | 2014-05-29 13:26:37 +0200 |
---|---|---|
committer | Adrian Kummerländer | 2014-05-29 13:26:37 +0200 |
commit | 3bc793d95293d40dbab62c593ce4ceaa86fae25b (patch) | |
tree | 07a0f99d72a074a75955a593318cc8bcd394f4c2 /src/transformation_facade.cc | |
parent | 52b60c1a8c23f11ab18fad06e0957490c7436e0a (diff) | |
download | InputXSLT-3bc793d95293d40dbab62c593ce4ceaa86fae25b.tar InputXSLT-3bc793d95293d40dbab62c593ce4ceaa86fae25b.tar.gz InputXSLT-3bc793d95293d40dbab62c593ce4ceaa86fae25b.tar.bz2 InputXSLT-3bc793d95293d40dbab62c593ce4ceaa86fae25b.tar.lz InputXSLT-3bc793d95293d40dbab62c593ce4ceaa86fae25b.tar.xz InputXSLT-3bc793d95293d40dbab62c593ce4ceaa86fae25b.tar.zst InputXSLT-3bc793d95293d40dbab62c593ce4ceaa86fae25b.zip |
Improved TransformationFacade error handling
* ErrorHandler class created in 5859cb6 now caches all errors instead of pushing them to std::cerr
** cached errors are retrieved by TransformationFacade's "generate" member method
* test frontend pushes all errors to std::cerr
* FunctionTransform returns errors to the calling template as XML
** FunctionTransform test case demonstrates how one may test for successful transformation
* "generate" member method returns std::string vector wrapped in a std::unique_ptr
** this is used as a kind of optional pointer, as the std::unique_ptr instance only wraps a vector if errors where actually generated
Diffstat (limited to 'src/transformation_facade.cc')
-rw-r--r-- | src/transformation_facade.cc | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/transformation_facade.cc b/src/transformation_facade.cc index fc7e1de..0f174d8 100644 --- a/src/transformation_facade.cc +++ b/src/transformation_facade.cc @@ -6,7 +6,6 @@ #include "boost/filesystem.hpp" #include <sstream> -#include <iostream> namespace InputXSLT { @@ -16,7 +15,7 @@ TransformationFacade::TransformationFacade( ): transformation_{}, transformer_(), - error_handler_(transformation) { + error_handler_() { this->transformer_.setEntityResolver(resolver); this->transformer_.setErrorHandler(&this->error_handler_); @@ -32,10 +31,10 @@ TransformationFacade::~TransformationFacade() { ); } -int TransformationFacade::generate( +auto TransformationFacade::generate( const std::string& targetPath, StylesheetParameterGuard& parameters -) { +) -> return_type { const boost::filesystem::path targetPathHelper( boost::filesystem::absolute(targetPath) ); @@ -53,22 +52,22 @@ int TransformationFacade::generate( ); } -int TransformationFacade::generate( +auto TransformationFacade::generate( std::basic_ostream<char>& targetStream, StylesheetParameterGuard& parameters -) { +) -> return_type { return this->generate( xalan::XSLTResultTarget(targetStream), parameters ); } -int TransformationFacade::generate( +auto TransformationFacade::generate( xalan::XSLTResultTarget&& outputTarget, StylesheetParameterGuard& -) { - std::stringstream emptyStream("<dummy/>"); - xalan::XSLTInputSource inputSource(emptyStream); +) -> return_type { + std::stringstream emptyStream("<dummy/>"); + xalan::XSLTInputSource inputSource(emptyStream); const int resultCode = this->transformer_.transform( inputSource, @@ -76,11 +75,18 @@ int TransformationFacade::generate( outputTarget ); - if ( resultCode != 0 ) { - std::cerr << this->transformer_.getLastError() << std::endl; + return_type errors(this->error_handler_.getCachedErrors()); + + if ( errors && resultCode != 0 ) { + errors->emplace_back( + "Transformation error with code " + + std::to_string(resultCode) + + ": " + + this->transformer_.getLastError() + ); } - return resultCode; + return errors; } } |