From e2bd850eb68aca942ce71ce4ffe22d17f6426ff1 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse <guillaume.rousse@renater.fr> Date: Thu, 9 Nov 2017 17:40:13 +0100 Subject: [PATCH] raise TT2 error if any --- bin/account-manager.pl.in | 7 +++++-- lib/IdPAccountManager/Tools.pm | 2 +- lib/IdPAccountManager/WebRequest.pm | 12 ++++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/bin/account-manager.pl.in b/bin/account-manager.pl.in index c170ed2..ff6bd5d 100755 --- a/bin/account-manager.pl.in +++ b/bin/account-manager.pl.in @@ -142,12 +142,15 @@ sub list_accounts { db => $db ); - die "failed to update simpleSAMLphp configuration file\n" - unless IdPAccountManager::Tools::update_ssp_authsources( + eval { + IdPAccountManager::Tools::update_ssp_authsources( $configuration->{templates_dir}, $configuration->{idp_accounts_file}, $accounts ); + }; + die "failed to update simpleSAMLphp configuration file: $EVAL_ERROR" + if $EVAL_ERROR; printf "Update simpleSamlPhp configuration file...\n"; } diff --git a/lib/IdPAccountManager/Tools.pm b/lib/IdPAccountManager/Tools.pm index c641f97..cf8dc9e 100644 --- a/lib/IdPAccountManager/Tools.pm +++ b/lib/IdPAccountManager/Tools.pm @@ -90,7 +90,7 @@ sub update_ssp_authsources { accounts => $accounts }; - return $tt2->process($template, $data, $output); + $tt2->process($template, $data, $output) or die $tt2->error(); } 1; diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm index 5580245..c87f50d 100755 --- a/lib/IdPAccountManager/WebRequest.pm +++ b/lib/IdPAccountManager/WebRequest.pm @@ -485,14 +485,18 @@ sub req_validate_token { } ## Update simpleSAMLphp configuration to enable test accounts - unless (IdPAccountManager::Tools::update_ssp_authsources( + eval { + IdPAccountManager::Tools::update_ssp_authsources( $self->{configuration}->{templates_dir}, $self->{configuration}->{idp_accounts_file}, \@accounts - )) { + ); + }; + if ($EVAL_ERROR) { push @{ $self->{out}->{errors} }, "accounts_creation_failed"; - $self->{logger}->error( - "Failed to create simpleSAMLphp configuration file" + $self->{logger}->errorf( + "Failed to create simpleSAMLphp configuration file: %s", + $EVAL_ERROR ); return undef; } -- GitLab