From 9ac7635590043660ed4e55ab5951ded862044b45 Mon Sep 17 00:00:00 2001 From: short <> Date: Sun, 28 Nov 2004 08:14:53 +0000 Subject: [PATCH] Fixed proper error reporting if MySQL --store fails. --- perlmail-submit | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/perlmail-submit b/perlmail-submit index 4711b74..cc76cca 100755 --- a/perlmail-submit +++ b/perlmail-submit @@ -230,16 +230,32 @@ my($keyword,$interval)=@_; } } +my $optwrap_err; +sub optwrap +{ +my($func,@args)=@_; + + # Prevent successful return due to --forkoff in the case of failed --store when using: + # perlmail-submit --store --forkoff --submit + if (!eval { &{$func}(@args); 1; }) { + $optwrap_err||=$@||$!; + die "!FINISH"; + die "NOTREACHED"; + } +} $Getopt::Long::ignorecase=0; -die if !GetOptions( - "initdb" ,\&initdb, - "store" ,\&store, - "forkoff",\&forkoff, - "submit" ,\&submit, - "pending",\&pending, - "dump" ,\&dump, - "clean:s",\&clean, +# &GetOptions will return success due to: die "!FINISH" +# but our error detection is done by $optwrap_err. +GetOptions( + "initdb" ,sub { optwrap \&initdb,@_; }, + "store" ,sub { optwrap \&store,@_; }, + "forkoff",sub { optwrap \&forkoff,@_; }, + "submit" ,sub { optwrap \&submit,@_; }, + "pending",sub { optwrap \&pending,@_; }, + "dump" ,sub { optwrap \&dump,@_; }, + "clean:s",sub { optwrap \&clean,@_; }, "V|version",sub { print "perlmail-submit: $VERSION\n"; exit 0; }, ); +die $optwrap_err if defined $optwrap_err; exit 0; -- 1.8.3.1