diff options
-rw-r--r-- | lib/Eval/Closure.pm | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Eval/Closure.pm b/lib/Eval/Closure.pm index 1ce0327..e45cb98 100644 --- a/lib/Eval/Closure.pm +++ b/lib/Eval/Closure.pm @@ -59,7 +59,13 @@ sub _clean_eval_closure { } my $code = eval _make_source(@_); - ($code, $@); + + if (!ref($code) || ref($code) ne 'CODE') { + undef $code; + $@ = "The 'source' parameter must return a subroutine reference"; + } + + return ($code, $@); } sub _make_source { |