|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Hey,
Not really having a Perl Problem so much as an Apache problem(I think). Here's the deal: I wrote a Perl CGI application which also uses DBI to do some database inserts on MySQL. The problem is that when there is an error with the DB portion - ie., an execute or something - I get back a 500 Internal Server error. What I would like to do is have the DBI::errstr print to the page as output so the user can email me the error. Is there a modification I can make to Apache so the script won't die when that occurs? I already turned of 'PrintError' and 'RaiseError' in DBI so I don't think that's it. Ok - specs: Platform: Windows Me (I know...I know... )Server: Apache 1.3.7 Database: MySQL Perl: ActivePerl623 I'm not sure what version of CGI.pm I have. Whichever one comes with ActivePerl623. Thanks for any help you can give.
__________________
- dsb - ![]() Perl Guy |
|
#2
|
||||
|
||||
|
If you are using the CGI.pm module with your script, you can use the use CGI::Carp qw(fatalsToBrowser); to bring up the error message to the browser. I would disable "PrintError" and use the "RaiseError", as the PrintError doesn't stop the script from executing if it encounters and an error, just raises the "warn". You can use a custom sub routine to display your errors too. When executing a query, just use something like this:
Code:
$dbh = DBI-> connect(.....) or &Error("Could not connect to Database");
# Subroutine Error
sub Error {
my $errmsg = shift;
print header();
print qq|Error: $errmsg - $DBI::err ($DBI::errstr)|;
}
This will bring up the error to the browser and halt any further execution of the script. Using the Error sub routine allows you to customize the error display too. You can modify your Apache srm.conf file to assign a custom error page to by modifying the "ErrorDocument" and adding a html page to be displayed instead of the generic error. There's many ways to customize your error handling. Hope these might give you some ideas. cheers, Mickalo
__________________
Thunder Rain Internet Publishing Custom Programming & Database development Providing Personal/Business Internet Solutions that work! |
|
#3
|
|||
|
|||
|
Thanks for responding.
The CGI::Carp thing sounds like it may work. I'll have to read the docs on that. I already had some custom error handling in the script. It just didn't work. I had disabled both PrintError and RaiseError. I usually do that with all my DBI scripts cuz I like to generate my own error messages in addition to $DBI::errstr. I'll look into CGI::Carp though. Thanks again. ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Perl - Apache |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|