From cf937eb7e1553bda7b6b1f7ec7014bb3ee6e759f Mon Sep 17 00:00:00 2001 From: Erik Huelsmann Date: Tue, 13 Apr 2021 23:33:12 +0200 Subject: [PATCH] Abort processing on error In relation to https://rt.cpan.org/Ticket/Display.html?id=111355 and gh #1, errors should be a stopping condition. --- lib/Rex/Template/TT.pm | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/Rex/Template/TT.pm b/lib/Rex/Template/TT.pm index 03b8d78..3dfd728 100644 --- a/lib/Rex/Template/TT.pm +++ b/lib/Rex/Template/TT.pm @@ -46,9 +46,16 @@ sub template_toolkit { # process template my $output = ''; - my $template = Template->new( { ABSOLUTE => 1 } ); + my $template = Template->new( { ABSOLUTE => 1 } ) + or do { + Rex::Logger::info( $Template::ERROR, 'error' ); + die $Template::ERROR; + }; $template->process( $template_path, $vars, \$output ) - || Rex::Logger::info( $template->error(), 'error' ); + or do { + Rex::Logger::info( $template->error(), 'error' ); + die $template->error(); + }; return $output; } @@ -65,11 +72,17 @@ sub import { validate_vars( $vars ); - my $template = Template->new; - + my $template = Template->new() + or do { + Rex::Logger::info( $Template::ERROR, 'error' ); + die $Template::ERROR; + }; my $output; $template->process( \$content, $vars, \$output ) - || Rex::Logger::info( $template->error(), 'error' ); + or do { + Rex::Logger::info( $template->error(), 'error' ); + die $template->error(); + }; return $output; };