SunQuest
           Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old February 22nd, 2001, 08:35 AM
dsb dsb is offline
PerlGuy
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2001
Posts: 714 dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 15 h 44 m 20 sec
Reputation Power: 36
Send a message via AIM to dsb
Wink

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

Reply With Quote
  #2  
Old February 22nd, 2001, 09:30 AM
mickalo's Avatar
mickalo mickalo is offline
Ole` Timer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: N.W. Iowa
Posts: 469 mickalo User rank is Private First Class (20 - 50 Reputation Level)mickalo User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 5 h 19 sec
Reputation Power: 8
Send a message via AIM to mickalo Send a message via MSN to mickalo
Thumbs up

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!

Reply With Quote
  #3  
Old February 22nd, 2001, 09:53 AM
dsb dsb is offline
PerlGuy
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2001
Posts: 714 dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 15 h 44 m 20 sec
Reputation Power: 36
Send a message via AIM to dsb
Wink

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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Perl - Apache


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway