From 3fdb26b1be0178d1a450405f6d1d3976c19b9587 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 12 May 2011 10:43:47 +0200 Subject: [PATCH] =?utf8?q?DBHookError=20Objekte=20haben=20jetzt=20Felder?= =?utf8?q?=20f=C3=BCr=20etwas=20einfachere=20Verwendung.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Conflicts: SL/X.pm --- SL/DB/Object/Hooks.pm | 6 +++++- SL/X.pm | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/SL/DB/Object/Hooks.pm b/SL/DB/Object/Hooks.pm index 00567559a..e47951407 100644 --- a/SL/DB/Object/Hooks.pm +++ b/SL/DB/Object/Hooks.pm @@ -44,7 +44,11 @@ sub run_hooks { foreach my $sub (@{ ( $hooks{$when} || { })->{ ref($object) } || [ ] }) { my $result = ref($sub) eq 'CODE' ? $sub->($object, @args) : $object->call_sub($sub, @args); - SL::X::DBHookError->throw(error => "${when} hook '" . (ref($sub) eq 'CODE' ? '' : $sub) . "' failed") if !$result; + die SL::X::DBHookError->new( + hook => (ref($sub) eq 'CODE' ? '' : $sub), + when => $when, + object => $object, + ) if !$result; } } diff --git a/SL/X.pm b/SL/X.pm index 8c130c3c9..0f206949b 100644 --- a/SL/X.pm +++ b/SL/X.pm @@ -5,6 +5,6 @@ use strict; use Exception::Lite qw(declareExceptionClass); declareExceptionClass('SL::X::FormError'); -declareExceptionClass('SL::X::DBHookError'); +declareExceptionClass('SL::X::DBHookError', [ '%s hook \'%s\' failed', qw(when hook object) ]); 1; -- 2.20.1