in reply to Re: Getting error messages from IIS with PerlScript
in thread Getting error messages from IIS with PerlScript

Here is what I have tried already.
<%@Language=PerlScript%> <% use strict; use Win32::ASP; use vars qw($Response $Request $Server); # Turn on buffering...allows us # to send headers whenever we want. $Response->{Buffer} = 1; # turn OFF page caching. This will hopefully # fix some of IIS's HORRIBLE shortcomings. $Response->{Expires} = 0; $Response->AddHeader('pragma', 'no-cache'); $Response->AddHeader('cache-control','private'); $SIG{__DIE__} = sub { $Response->Write("<h1>Death!</h1>"); }; $SIG{__WARN__} = sub { $Response->Write("<h1>Warning!</h1>"); }; %> <%= my $bad_value = 4/0 %>
And here is what it begets (in the Browser window only, nothing in logs.
PerlScript Error error '80004005' (in cleanup) Illegal division by zero /index.asp, line 18

I am trying to capture that output and throw it to an error log. The problem is that I haven't been about to capture it. If matters weren't bad enough, I have no access to the administration of the host server. I can only access my directory (Global.asa is not an option).

Thank you,
Kristofer Hoch

Replies are listed 'Best First'.
Re^3: Getting error messages from IIS with PerlScript
by ikegami (Patriarch) on Aug 09, 2005 at 14:58 UTC

    You said you wanted to log the errors, not send them to the client. I think the handlers are getting called, and you can log the errors from within them.

    If you want to send the error to the client, you'll either need to do some fancy ASP stuff, or use eval BLOCK. For example,

    eval { ... something_that_might_die(); ... }; if ($@) { # It died. # The error message is in $@ ... }

    That won't catch division by zero, but it will catch just about everything else. To catch division by zero, check the denominator before dividing.