Skip to content

Commit

Permalink
Abort processing on error
Browse files Browse the repository at this point in the history
In relation to https://rt.cpan.org/Ticket/Display.html?id=111355 and gh #1, errors should be a stopping condition.
  • Loading branch information
ehuelsmann authored Apr 13, 2021
1 parent 8ef8d4f commit cf937eb
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lib/Rex/Template/TT.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
};
Expand Down

0 comments on commit cf937eb

Please sign in to comment.