Greetings, I think there are basically two ways to look at it -- both options having being mentioned already -- as a function of your intentions.
Based on your latest response I'm guessing that you're primarily interested in doing this for debugging purposes. If that's the case then you're simplest solution will be to "use CGI::Carp 'fatalsToBrowser'" at the top of your code and then down below you can use "die" statements and accomplish what you're looking for in one line. The errors will be dumped right into the browser window. If, however, you're looking for application level responses that will persist even once you've completed coding and rolled your app out into the real world, then you certainly would want to use templates and design these responses into the fabric of your app. Having errors and such directly sent to the browser would be a pretty bad idea. But that's just my $0.02. Hope it helps... Cheers | (dk) -- You can doubt anything, if you think about it long enough d.o.r.l.a.n.d.o ...k.e.i.s.e... On Wed, 17 Oct 2001, Odounga y'Oyabi wrote: > Thanks for the quick reply. I've thought of doing this. The problem is I > don't think it's efficient since I have to open and return a template every > time an exception occurred. > > This means, instead of two simple lines > > warn "blablabla!\n"; > return; > > I will have > > my $template = HTML::Template->new( filename => "error_screen" ); > $template->param( > VERSION => $VERSION, > RELEASE => $RELEASE, > RUN_MODE => 'this_run_mode', > ERROR_MSG => 'Something weird occurred!\n" > ); > return $template->output; > > I will have three lines of code! > > I was looking for something like a call to a specialized routine whic�h got > the error message passed in. Like the "AUTOLOAD" run-mode. Unfortunately, I > don't know how to pass an error message to the method which is called by > "AUTOLOAD" and don't even know how to cause this method to be called. > > Loads'f thanks for your feedback. Your answer is probably the easiest way. > > > > > Roses Longin Odounga > > Netset Consulting > Falltorweg 4 > D-65428 R�sselsheim > Tel. +49 (0) 6142 - 938978 > GSM +49 (0) 173 - 3201063 > Mailto [EMAIL PROTECTED] > http://www.gabon-net.com > > > > >From: [EMAIL PROTECTED] > >To: [EMAIL PROTECTED], [EMAIL PROTECTED] > >Subject: RE: [cgiapp] Error Handling with CGI::Application > >Date: Wed, 17 Oct 2001 09:35:28 -0400 > > > > > >Warn will pump it into the web servers logs not out to the browser. > > > >I've done a few things to handle what your thinking: > > > >Use 'die' instead of warn with fatalsToBrowser turned on for CGI (Search > >CGI.pm documentation for fatalsToBrowser > > > >For a neater appearance, make a template and stick the error code into > >it and return it instead > > > >Another thing I do is make a sysmessage field in my templates in a > >comment block. I set it to whatever debug info I want to drop - when I > >get the page I view source and there is all my benchmarking, warnings, > >etc... > > > > > >-----Original Message----- > >From: odounga [mailto:[EMAIL PROTECTED]] > >Sent: Wednesday, October 17, 2001 7:46 AM > >To: cgiapp > >Subject: [cgiapp] Error Handling with CGI::Application > > > > > >Hi! > > > >I'm a Perl novice and currently trying to develop a CGI::Application > >based > >web-system. > > > >I can't figure out how to display an error page to the user when an > >exception occurred in a sub called by a run-mode. > > > >In the sub I'm doing a conditional like this > > > >unless ( $object->do_yourself() ) { > > warn "CRITICAL: Error, object can not do itself!\n"; > > return; > >} > > > >I'm looking for a mechanism for returning this error message to the > >browser. > >Currently, it just warn "Document contains no data" and didn't update > >the > >screen. > > > >Thanks for your support and invaluable time. > > > >Regards, > > > >Roses Longin Odounga > > > >Falltorweg 4 > >D-65428 R�sselsheim > >Tel. +49 (0) 6142 - 938978 > >GSM +49 (0) 173 - 3201063 > >Mailto [EMAIL PROTECTED] > >http://www.gabon-net.com > > > > > >_________________________________________________________________ > >Downloaden Sie MSN Explorer kostenlos unter > >http://explorer.msn.de/intl.asp > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > _________________________________________________________________ > Downloaden Sie MSN Explorer kostenlos unter http://explorer.msn.de/intl.asp > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
