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' ? '<anonymous sub>' : $sub) . "' failed") if !$result;
+ die SL::X::DBHookError->new(
+ hook => (ref($sub) eq 'CODE' ? '<anonymous sub>' : $sub),
+ when => $when,
+ object => $object,
+ ) if !$result;
}
}
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;