Merge branch 'b-3.6.1' of ../kivitendo-erp_20220811
[kivitendo-erp.git] / SL / DB / Object / Hooks.pm
index 371e445..6a54869 100644 (file)
@@ -44,10 +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,
-                                object_type => ref($object))
+    SL::X::DBHookError->throw(when        => $when,
+                              hook        => (ref($sub) eq 'CODE' ? '<anonymous sub>' : $sub),
+                              object      => $object,
+                              object_type => ref($object))
       if !$result;
   }
 }