From: Moritz Bunkus Date: Thu, 13 Jan 2011 13:09:26 +0000 (+0100) Subject: $form->error() kann optional eine Exception werfen, anstatt etwas auszugeben und... X-Git-Tag: release-2.6.3~61^2~7^2~1^2~2^2~16 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=8c31500d9372e4e1585b895ce4d43d67a5e517e5;p=kivitendo-erp.git $form->error() kann optional eine Exception werfen, anstatt etwas auszugeben und das Programm zu beenden Version ohne Exception::Class --- diff --git a/SL/Form.pm b/SL/Form.pm index 5cc9e1e6e..90c8c9b99 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -448,13 +448,23 @@ sub hide_form { $main::lxdebug->leave_sub(); } +sub throw_on_error { + my ($self, $code) = @_; + local $self->{__ERROR_HANDLER} = sub { die({ error => $_[0] }) }; + $code->(); +} + sub error { $main::lxdebug->enter_sub(); $main::lxdebug->show_backtrace(); my ($self, $msg) = @_; - if ($ENV{HTTP_USER_AGENT}) { + + if ($self->{__ERROR_HANDLER}) { + $self->{__ERROR_HANDLER}->($msg); + + } elsif ($ENV{HTTP_USER_AGENT}) { $msg =~ s/\n/
/g; $self->show_generic_error($msg); @@ -866,6 +876,12 @@ sub show_generic_error { my ($self, $error, %params) = @_; + if ($self->{__ERROR_HANDLER}) { + $self->{__ERROR_HANDLER}->($error); + $main::lxdebug->leave_sub(); + return; + } + my $add_params = { 'title_error' => $params{title}, 'label_error' => $error,