http://qs1969.pair.com?node_id=269781

archon has asked for the wisdom of the Perl Monks concerning the following question:

I'm using CGI::Application. The way it works is a form parameter sets a particular mode. In this mode, a subroutine is called and that subroutine returns an HTML::Template->output which produces the page.

So in one mode I have a method that calls another subroutine which returns two list references. It is possible for this subroutine to come across an error and produce an error message. If it does get an error, I would like the calling method to return an error page HTML::Template with the error message. Otherwise, I would like it to take the two list refs and go about its business.

My question, then, is what is the proper way to go about doing this? I tried (heh) using Error.pm and throwing an exception in the subroutine, but I can't return() from the try block. I could return the error string instead from the subroutine and then have the method figure out if something went wrong using ref(), but that feels dirty to me.

Thanks