summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Retout <tim@retout.co.uk>2012-09-26 18:21:27 +0100
committerTim Retout <tim@retout.co.uk>2012-09-26 21:42:06 +0100
commitbc9ad85ca4a70e5b14abe79ea59e848ee3b21e23 (patch)
tree650732558e3ba6735a80a99d7ec7285b57809568
parent106a1b4eba1303e1d989eb67eff63ed864500578 (diff)
installer: Move exiter.pm error handling into installer.pm
Change-Id: I50e3ee8ff88f313b82ea617e354334d85fb453e0
-rw-r--r--solenv/bin/modules/installer.pm37
-rw-r--r--solenv/bin/modules/installer/exiter.pm72
2 files changed, 39 insertions, 70 deletions
diff --git a/solenv/bin/modules/installer.pm b/solenv/bin/modules/installer.pm
index 025d47189305..49e2e3c6b2ab 100644
--- a/solenv/bin/modules/installer.pm
+++ b/solenv/bin/modules/installer.pm
@@ -95,8 +95,12 @@ sub main {
run();
};
if ($@) {
- warn "$@\n";
+ my $message = "ERROR: $@";
+
+ warn "$message\n";
$exit_code = -1;
+
+ cleanup_on_error($message);
}
installer::logger::stoptime();
@@ -1820,4 +1824,35 @@ sub run {
} # end of iteration for one language group
}
+sub cleanup_on_error {
+ my $message = shift;
+
+ # If an installation set is currently created, the directory name
+ # is saved in $installer::globals::saveinstalldir. If this
+ # directory name contains "_inprogress", it has to be renamed to
+ # "_witherror".
+ if ( $installer::globals::saveinstalldir =~ /_inprogress/ ) {
+ installer::systemactions::rename_string_in_directory($installer::globals::saveinstalldir, "_inprogress", "_witherror");
+ }
+
+ # Removing directories created in the output tree.
+ installer::worker::clean_output_tree();
+
+ $installer::globals::logfilename = $installer::globals::exitlog . $installer::globals::logfilename;
+
+ my @log = (@installer::globals::logfileinfo, @installer::globals::globallogfileinfo);
+
+ push(@log, "\n" . '*' x 65 . "\n");
+ push(@log, $message);
+ push(@log, '*' x 65 . "\n");
+
+ installer::files::save_file($installer::globals::logfilename, \@log);
+
+ print("ERROR, saved logfile $installer::globals::logfilename is:\n");
+ open(my $log, "<", $installer::globals::logfilename);
+ print ": $_" while (<$log>);
+ print "\n";
+ close($log);
+}
+
1;
diff --git a/solenv/bin/modules/installer/exiter.pm b/solenv/bin/modules/installer/exiter.pm
index 55a1dbb57850..516565f49308 100644
--- a/solenv/bin/modules/installer/exiter.pm
+++ b/solenv/bin/modules/installer/exiter.pm
@@ -30,79 +30,13 @@ package installer::exiter;
use strict;
use warnings;
-use installer::files;
-use installer::globals;
-use installer::logger;
-use installer::systemactions;
-use installer::worker;
-
-############################################
-# Exiting the program with an error
-# This function is used instead of "die"
-############################################
+use Carp;
sub exit_program
{
- my ($message, $function) = @_;
-
- # If an installation set is currently created, the directory name is saved in $installer::globals::saveinstalldir
- # If this directory name matches with "_inprogress", it has to be renamed into "_witherror"
-
- if ( $installer::globals::saveinstalldir =~ /_inprogress/ ) { installer::systemactions::rename_string_in_directory($installer::globals::saveinstalldir, "_inprogress", "_witherror"); }
-
- installer::worker::clean_output_tree(); # removing directories created in the output tree
-
- # If @installer::globals::logfileinfo is not empty, it can be used.
- # Otherwise the content of @installer::globals::globallogfileinfo has to be used.
-
- my $infoline;
-
- $installer::globals::logfilename = $installer::globals::exitlog . $installer::globals::logfilename;
-
- if ( ! $installer::globals::globalinfo_copied ) { installer::logger::copy_globalinfo_into_logfile(); }
-
- if ( $#installer::globals::logfileinfo > -1 )
- {
- $infoline = "\n***************************************************************\n";
- push(@installer::globals::logfileinfo, $infoline);
-
- $infoline = "$message\n";
- push(@installer::globals::logfileinfo, $infoline);
-
- $infoline = "in function: $function\n";
- push(@installer::globals::logfileinfo, $infoline);
-
- $infoline = "***************************************************************\n";
- push(@installer::globals::logfileinfo, $infoline);
-
- installer::files::save_file($installer::globals::logfilename ,\@installer::globals::logfileinfo);
- }
- else
- {
- $infoline = "\n***************************************************************\n";
- push(@installer::globals::globallogfileinfo, $infoline);
-
- $infoline = "$message\n";
- push(@installer::globals::globallogfileinfo, $infoline);
-
- $infoline = "in function: $function\n";
- push(@installer::globals::globallogfileinfo, $infoline);
-
- $infoline = "***************************************************************\n";
- push(@installer::globals::globallogfileinfo, $infoline);
-
- installer::files::save_file($installer::globals::logfilename ,\@installer::globals::globallogfileinfo);
- }
- installer::logger::print_error("$message\nin function: $function");
- print("ERROR, saved logfile $installer::globals::logfilename is:\n");
- open(LOG, "<", $installer::globals::logfilename);
- print ": $_" while (<LOG>);
- print "\n";
- close(LOG);
-
- installer::logger::stoptime();
+ my $message = shift;
- exit(-1);
+ croak $message;
}
1;