DB-Object-Hooks: bei Exception in Hook auch Objekttyp in Exception-Text aufnehmen
authorMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 4 Apr 2013 07:53:04 +0000 (09:53 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 19 Apr 2013 12:22:31 +0000 (14:22 +0200)
SL/DB/Object/Hooks.pm
SL/X.pm

index 3839286..371e445 100644 (file)
@@ -44,9 +44,10 @@ sub run_hooks {
 
   foreach my $sub (@{ ( $hooks{$when} || { })->{ ref($object) } || [ ] }) {
     my $result = ref($sub) eq 'CODE' ? $sub->($object, @args) : $object->call_sub($sub, @args);
-    die SL::X::DBHookError->new(when   => $when,
-                                hook   => (ref($sub) eq 'CODE' ? '<anonymous sub>' : $sub),
-                                object => $object)
+    die SL::X::DBHookError->new(when        => $when,
+                                hook        => (ref($sub) eq 'CODE' ? '<anonymous sub>' : $sub),
+                                object      => $object,
+                                object_type => ref($object))
       if !$result;
   }
 }
diff --git a/SL/X.pm b/SL/X.pm
index 0f20694..552e5ef 100644 (file)
--- 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', [ '%s hook \'%s\' failed', qw(when hook object) ]);
+declareExceptionClass('SL::X::DBHookError', [ '%s hook \'%s\' for object type \'%s\' failed', qw(when hook object_type object) ]);
 
 1;