On Wed, 18 Jul 2001, Scott Every wrote:
> i have a fairly simple mod-perl script which returns data from a mysql db
>
> on occasion for no apparent reason an internal error screen pops up. if
> reloaded the page works just fine.
>
> the logs contain this message:
> "exit" is not exported by the GLOB(0x88414cc) module at (eval 397) line 1
> [Wed Jul 18 14:13:29 2001] [error] Can't continue after import errors at
> (eval 397) line 1
> BEGIN failed--compilation aborted at (eval 397) line 1.
>
> my script doesn't use any 'exit' statements so i am not sure what to do.
> any ideas what i'm doing wrong?
You are running under Apache::Registry, aren't you? Check this out:
http://perl.apache.org/guide/porting.html#Terminating_requests_and_process
To debug the problem you need the function calls trace:
Try to install this handler:
require Carp;
$SIG{__DIE__} = \&Carp::confess;
so you will see a trace.
Notice that this can break the error propogations within eval {} blocks,
per: http://perl.apache.org/guide/perl.html#Catching_Uncaught_Exceptions
Another approach with recent Perls would be something like this
(including the test case, with properly working eval {} catching blocks):
--------------------------
require Carp;
use subs qw(CORE::GLOBAL::die);
*CORE::GLOBAL::die = sub {
if ($_[0] =~ /"exit" is not exported/){
local *CORE::GLOBAL::die = sub { CORE::die(@_) };
Carp::confess(@_); # Carp uses die() internally!
} else {
CORE::die(@_); # could write &CORE::die to forward @_
}
};
eval { foo(); }; warn $@ if $@;
print "\n";
eval { poo(); }; warn $@ if $@;
sub foo{ bar(); }
sub bar{ die qq{"exit" is not exported}}
sub poo{ tar(); }
sub tar{ die "normal exit"}
--------------------------
prints:
$ perl -w test
Subroutine die redefined at test line 5.
"exit" is not exported at test line 6
main::__ANON__('"exit" is not exported') called at test line 17
main::bar() called at test line 16
main::foo() called at test line 12
eval {...} called at test line 12
normal exit at test line 5.
the 'local' in:
local *CORE::GLOBAL::die = sub { CORE::die(@_) };
is important, so you won't lose the overloaded CORE::GLOBAL::die.
Matt, how about updating your "Exception Handling for mod_perl" section to
use my hairy snippet? :) Well I just wrote it, so it's possible it can be
made less hairy :)
*CORE::GLOBAL:: is a cool thing!
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/