diff options
Diffstat (limited to 'lib/Fripost/Schema/Util.pm')
-rw-r--r-- | lib/Fripost/Schema/Util.pm | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/lib/Fripost/Schema/Util.pm b/lib/Fripost/Schema/Util.pm index 2c71411..32f0237 100644 --- a/lib/Fripost/Schema/Util.pm +++ b/lib/Fripost/Schema/Util.pm @@ -185,38 +185,32 @@ sub ldap_error { $error = $mesg->error if $mesg->code; } - return 1 unless $error; - - if (defined $options{'-error'}) { - ${$options{'-error'}} = $error; - } - else { - die $error, "\n"; - } + &softdie( $error, %options ); } -sub assert { - my $what = shift; +sub softdie { + my $mesg = shift; my %options = @_; - return $what if defined $what; - die "Not defined.\n" unless defined $options{'-die'}; + return 1 unless $mesg; if (defined $options{'-error'}) { - ${$options{'-error'}} = $options{'-die'}; + ${$options{'-error'}} = $mesg; + } + elsif (exists $options{'-error'}) { + return; # Ignore the error } else { - die $options{'-die'}, "\n"; + die $mesg, "\n"; } } -sub softdie { - my $mesg = shift; +sub assert { + my $what = shift; my %options = @_; - return 1 unless $mesg; - $options{'-die'} = $mesg; - &assert (undef, %options); + return $what if $what; + &softdie($options{'-die'} // "Not defined.", %options); } sub dn2mail { |