From 328102ef2960a93484fb478e6815df4cdb38a9bb Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 29 Oct 2019 14:46:22 +0100 Subject: [PATCH] TT#68300 Add an explicit newline to die calls This disables the magic behavior of die() which prints the filename and line number. Change-Id: I6f89d88c8b0f2c45880f4a93d01c8e9cfa214f56 --- bin/ngcp-credit-warning | 10 +++++----- bin/ngcp-fraud-notifier | 16 +++++++++------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/bin/ngcp-credit-warning b/bin/ngcp-credit-warning index 129dfd4..49093f1 100755 --- a/bin/ngcp-credit-warning +++ b/bin/ngcp-credit-warning @@ -49,7 +49,7 @@ sub usage { sub load_config { $config = XML::Simple->new()->XMLin($config_file, ForceArray => [ 'credit_warnings' ]) - or die "Cannot load config: $config_file: $ERRNO"; + or die "Cannot load config: $config_file: $ERRNO\n"; return; } @@ -94,7 +94,7 @@ EOF ); Email::Sender::Simple->send($email, { transport => $transport }) - or die sprintf "Cannot send credit warning notification to %s: $ERRNO", + or die sprintf "Cannot send credit warning notification to %s: $ERRNO\n", $email->header('To'); return; } @@ -110,7 +110,7 @@ sub get_data { ); my @result = (); while (my $res = $client->next_page($uri)) { - die $res->result unless $res->is_success; + die "$res->result\n" unless $res->is_success; my $res_hash = $res->as_hash; my $data = $res_hash->{_embedded}{'ngcp:'.$link}; if ('ARRAY' eq ref $data) { @@ -143,10 +143,10 @@ sub main { : [ $config->{credit_warnings} ]; foreach my $cwarning (@{$cwarnings}) { unless ($cwarning->{recipients}) { - die "No recipients defined for domain: $cwarning->{domain}"; + die "No recipients defined for domain: $cwarning->{domain}\n"; } unless ($cwarning->{domain}) { - die "Missing domain in a credit warning check"; + die "Missing domain in a credit warning check\n"; } my @contracts; get_data(sprintf('/api/customerbalances/?no_count=true&domain=%s&prepaid=1', diff --git a/bin/ngcp-fraud-notifier b/bin/ngcp-fraud-notifier index 40ffffa..de33e7e 100755 --- a/bin/ngcp-fraud-notifier +++ b/bin/ngcp-fraud-notifier @@ -66,7 +66,8 @@ sub usage { sub load_config { $config = XML::Simple->new()->XMLin($config_file, ForceArray => 0) - or die "Cannot load config: $config_file: $ERRNO"; + or die "Cannot load config: $config_file: $ERRNO\n"; + return; } @@ -80,7 +81,7 @@ sub get_data { my @result = (); while (my $res = $client->next_page($uri)) { - die $res->result unless $res->is_success; + die "$res->result\n" unless $res->is_success; my $res_hash = $res->as_hash; my $data = $res_hash->{_embedded}{'ngcp:'.$link}; if ('ARRAY' eq ref $data) { @@ -117,7 +118,8 @@ sub get_email_template { } unless ($selected_template) { - die sprintf "No template 'customer_fraud_%s_default_email' OR 'customer_fraud_%s_email' is defined.", $lock_type, $lock_type; + die sprintf "No template 'customer_fraud_%s_default_email' OR 'customer_fraud_%s_email' is defined.\n", + $lock_type, $lock_type; } return $selected_template; @@ -151,9 +153,9 @@ sub send_email { $template->{$field} = $out if $out; } - die "'To' header is empty in the email" unless $event->{interval_notify}; - die "'From' header is empty in the email" unless $template->{from_email}; - die "'Subject' header is empty in the email" unless $template->{subject}; + die "'To' header is empty in the email\n" unless $event->{interval_notify}; + die "'From' header is empty in the email\n" unless $template->{from_email}; + die "'Subject' header is empty in the email\n" unless $template->{subject}; my $transport = Email::Sender::Transport::Sendmail->new; my $email = Email::Simple->create( @@ -166,7 +168,7 @@ sub send_email { ); Email::Sender::Simple->send($email, { transport => $transport }) - or die sprintf "Cannot send fraud daily lock notification to %s: $ERRNO", + or die sprintf "Cannot send fraud daily lock notification to %s: $ERRNO\n", $email->header('To'); update_notify_status($event);