Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Getting error messages from IIS with PerlScript

by ikegami (Patriarch)
on Aug 09, 2005 at 13:53 UTC ( #482212=note: print w/replies, xml ) Need Help??

in reply to Getting error messages from IIS with PerlScript

Have you tried $SIG{__WARN__} and $SIG{__DIE__}. They are documented in perlvar.

Replies are listed 'Best First'.
Re^2: Getting error messages from IIS with PerlScript
by krisahoch (Deacon) on Aug 09, 2005 at 14:48 UTC
    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

      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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://482212]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2022-06-29 06:03 GMT
Find Nodes?
    Voting Booth?
    My most frequent journeys are powered by:

    Results (94 votes). Check out past polls.