[cgiapp] Graceful Error Handling in CGI::App (compile / init stages)

P Kishor punk.kish at gmail.com
Wed Jul 7 10:00:37 EDT 2010


On Wed, Jul 7, 2010 at 8:43 AM, Michael Peters <mpeters at plusthree.com> wrote:
> On 07/07/2010 05:16 AM, Mike Tonks wrote:
>
>> 1) So and so CPAN module is not found
>>
>> 2) Config file not found (ConfigAuto - in cgiapp_init)
>>
>> currently these produce an ugly 500 Server Error and loeave you
>> searching in the apache log for the problem.
>>
>> For 1) is there a better way than:
>>
>> use Data::Dumper;
>> use XML::Simple;
>> use Date::Manip;
>> use HTML::FromText;
>
> It's verbose, but the only thing I know of is:
>
> BEGIN {
>   eval { require Data::Dumper; Data::Dumper::import() };
>   die "Can't find Data::Dumper module: $@" if $@;
> }
>
> repeated for each one.


>From what I remember, the installation process for MovableType 4 (the
free, community version a couple of versions earlier, when SQLite was
still supported) was really fantastic. The install script ran a check
and figured out the missing modules, printed out a nice list, and, I
think, even offered to install them.

I would love to learn how to do that. I guess I could open the tin and
peek inside...

>
>> that will safely try to load the modules needed and allow me to report
>> via a nice formatted error page what's wrong?
>
> Btw, it's not a good idea to show detailed error messages on your
> website. It's a security concern as it gives out more information to
> attackers than necessary. So it's not a good idea to start.
>
> Error logs are your friend. Learn them and learn to love them.
>
>> 2) If I hit an error in cgiapp_init, is there a way to redirect to an
>> error page, as per prerun_mode() ?
>
> There doesn't appear to be. There's the error_mode() but that only seems
> to work for run modes, not other stages.
>
> --
> Michael Peters
> Plus Three, LP
>
> #####  CGI::Application community mailing list  ################
> ##                                                            ##
> ##  To unsubscribe, or change your message delivery options,  ##
> ##  visit:  http://lists.openlib.org/mailman/listinfo/cgiapp    ##
> ##                                                            ##
> ##  Web archive:   http://lists.openlib.org/pipermail/cgiapp/   ##
> ##  Wiki:          http://cgiapp.erlbaum.net/                 ##
> ##                                                            ##
> ################################################################
>
>



-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================


More information about the cgiapp mailing list