make sure pluggable passes through exceptions
This commit is contained in:
parent
0efa62a73c
commit
aba7dd7be4
1 changed files with 13 additions and 3 deletions
|
|
@ -193,6 +193,9 @@ object.
|
||||||
sub instanciate {
|
sub instanciate {
|
||||||
my ($module, $sub, $params) = @_;
|
my ($module, $sub, $params) = @_;
|
||||||
if ( ! eval { load($module); 1 } ) {
|
if ( ! eval { load($module); 1 } ) {
|
||||||
|
if ( ref $@ ) {
|
||||||
|
die $@;
|
||||||
|
}
|
||||||
croak "Could not instanciate object using $sub on $module: $@";
|
croak "Could not instanciate object using $sub on $module: $@";
|
||||||
}
|
}
|
||||||
# Module loaded properly
|
# Module loaded properly
|
||||||
|
|
@ -229,7 +232,7 @@ my %moduleError;
|
||||||
sub load {
|
sub load {
|
||||||
my $module = shift;
|
my $module = shift;
|
||||||
if ($moduleError{$module}) {
|
if ($moduleError{$module}) {
|
||||||
croak "Could not load $module because $moduleError{$module}";
|
croak $moduleError{$module};
|
||||||
}
|
}
|
||||||
|
|
||||||
# Try to load the module
|
# Try to load the module
|
||||||
|
|
@ -239,8 +242,13 @@ sub load {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$moduleError{$module} = $@;
|
if ( ref $@ ) {
|
||||||
croak "Could not load $module because $@";
|
$moduleError{$module} = $@;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$moduleError{$module} = "Could not load $module because $@";
|
||||||
|
}
|
||||||
|
croak $moduleError{$module};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -267,6 +275,8 @@ An array reference of parameters to pass in to the sub routine.
|
||||||
sub run {
|
sub run {
|
||||||
my ($module, $sub, $params) = @_;
|
my ($module, $sub, $params) = @_;
|
||||||
if (! eval { load($module); 1 }) {
|
if (! eval { load($module); 1 }) {
|
||||||
|
die $@
|
||||||
|
if ref $@;
|
||||||
croak "Unable to run $sub on $module: $@";
|
croak "Unable to run $sub on $module: $@";
|
||||||
}
|
}
|
||||||
elsif (my $sub = $module->can($sub)) {
|
elsif (my $sub = $module->can($sub)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue