Hello,

I was just working with CGI::App today and ran into a situation I've
run into several times before: I got an internal server error because a
template could not be found when load_tmpl() was called. It would be
nice if CGI::App could systematically address this issue by providing
some error handling for this case. Here's a specific proposal to do
that:

1. A new parameter would be added as a CGI::App object creation option to
  toggle this feature on, such as handle_load_tmpl_errors. By default
this would be set to zero, giving the current functionality of manual
handling.

2. With this option enabled, if loading the template failed, CGI would
return a generic error page to the effect of "Template loading failed,
the error was: $@".

3. A second constructor option could be added to specify a template to
use to display this error. If loading this template failed, either the
logic from (2.) could be used, or it could just die. This option might
work like: template_error_template => 'template_error.tmpl'
One token would be provided to this template, which would contain the
output of HTML::Template's death message.

I suppose this system could generalized to also report on the failure of
HTML::Template's param() function, as well as some parts of CGI::App's
API itself.

I could see this being used a couple of different ways: Some folks might
turn on these features during development to speed up debugging a little
bit, and some might leave these errors on in production to pass some
version of the errors through to the user.

Would other folks find this sort of thing useful?

  -mark

http://mark.stosberg.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to