From aba7dd7be43862b33653e4780d505cab7cd8fbeb Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Sun, 18 Apr 2010 18:51:25 -0500 Subject: [PATCH] make sure pluggable passes through exceptions --- lib/WebGUI/Pluggable.pm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/Pluggable.pm b/lib/WebGUI/Pluggable.pm index c5608288c..80a95df9c 100644 --- a/lib/WebGUI/Pluggable.pm +++ b/lib/WebGUI/Pluggable.pm @@ -193,6 +193,9 @@ object. sub instanciate { my ($module, $sub, $params) = @_; if ( ! eval { load($module); 1 } ) { + if ( ref $@ ) { + die $@; + } croak "Could not instanciate object using $sub on $module: $@"; } # Module loaded properly @@ -229,7 +232,7 @@ my %moduleError; sub load { my $module = shift; if ($moduleError{$module}) { - croak "Could not load $module because $moduleError{$module}"; + croak $moduleError{$module}; } # Try to load the module @@ -239,8 +242,13 @@ sub load { return 1; } else { - $moduleError{$module} = $@; - croak "Could not load $module because $@"; + if ( ref $@ ) { + $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 { my ($module, $sub, $params) = @_; if (! eval { load($module); 1 }) { + die $@ + if ref $@; croak "Unable to run $sub on $module: $@"; } elsif (my $sub = $module->can($sub)) {