From 27ffa16a85221662dee49da0f210312383341240 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 3 May 2011 17:27:07 +0200 Subject: [PATCH] Umstellung Form::throw_on_error auf Verwendung von Exception::Lite anstelle von Hashrefs --- SL/BackgroundJob/CreatePeriodicInvoices.pm | 2 +- SL/Form.pm | 3 ++- SL/X.pm | 9 +++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 SL/X.pm diff --git a/SL/BackgroundJob/CreatePeriodicInvoices.pm b/SL/BackgroundJob/CreatePeriodicInvoices.pm index c725a6fec..559fd0299 100644 --- a/SL/BackgroundJob/CreatePeriodicInvoices.pm +++ b/SL/BackgroundJob/CreatePeriodicInvoices.pm @@ -240,7 +240,7 @@ sub _print_invoice { eval { $form->parse_template(\%::myconfig); 1; - } || die $EVAL_ERROR->{error}; + } || die $EVAL_ERROR->getMessage; }); } diff --git a/SL/Form.pm b/SL/Form.pm index b63421750..b3a3e23df 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -62,6 +62,7 @@ use SL::Menu; use SL::OE; use SL::Template; use SL::User; +use SL::X; use Template; use URI; use List::Util qw(first max min sum); @@ -458,7 +459,7 @@ sub hide_form { sub throw_on_error { my ($self, $code) = @_; - local $self->{__ERROR_HANDLER} = sub { die({ error => $_[0] }) }; + local $self->{__ERROR_HANDLER} = sub { die SL::X::FormError->new($_[0]) }; $code->(); } diff --git a/SL/X.pm b/SL/X.pm new file mode 100644 index 000000000..ce7552c1e --- /dev/null +++ b/SL/X.pm @@ -0,0 +1,9 @@ +package SL::X; + +use strict; + +use Exception::Lite qw(declareExceptionClass); + +declareExceptionClass('SL::X::FormError'); + +1; -- 2.20.1