Revision 8c31500d
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
448 | 448 |
$main::lxdebug->leave_sub(); |
449 | 449 |
} |
450 | 450 |
|
451 |
sub throw_on_error { |
|
452 |
my ($self, $code) = @_; |
|
453 |
local $self->{__ERROR_HANDLER} = sub { die({ error => $_[0] }) }; |
|
454 |
$code->(); |
|
455 |
} |
|
456 |
|
|
451 | 457 |
sub error { |
452 | 458 |
$main::lxdebug->enter_sub(); |
453 | 459 |
|
454 | 460 |
$main::lxdebug->show_backtrace(); |
455 | 461 |
|
456 | 462 |
my ($self, $msg) = @_; |
457 |
if ($ENV{HTTP_USER_AGENT}) { |
|
463 |
|
|
464 |
if ($self->{__ERROR_HANDLER}) { |
|
465 |
$self->{__ERROR_HANDLER}->($msg); |
|
466 |
|
|
467 |
} elsif ($ENV{HTTP_USER_AGENT}) { |
|
458 | 468 |
$msg =~ s/\n/<br>/g; |
459 | 469 |
$self->show_generic_error($msg); |
460 | 470 |
|
... | ... | |
866 | 876 |
|
867 | 877 |
my ($self, $error, %params) = @_; |
868 | 878 |
|
879 |
if ($self->{__ERROR_HANDLER}) { |
|
880 |
$self->{__ERROR_HANDLER}->($error); |
|
881 |
$main::lxdebug->leave_sub(); |
|
882 |
return; |
|
883 |
} |
|
884 |
|
|
869 | 885 |
my $add_params = { |
870 | 886 |
'title_error' => $params{title}, |
871 | 887 |
'label_error' => $error, |
Auch abrufbar als: Unified diff
$form->error() kann optional eine Exception werfen, anstatt etwas auszugeben und das Programm zu beenden
Version ohne Exception::Class