Engwar

Chintana Wilamuna's weblog

StockTrader client using Catalyst

with 4 comments

I’ve been rewriting the Perl StockTrader client using Catalyst for the past week or so. The first version of the client was done using (gasp!) Perl/CGI. So it was about time to do it right. Thanks to the excellent documentation Catalyst provide, it was a straightforward task.

The main annoyance I faced was the lack of a proper error reporting mechanism. When you have an error on your controller, the script that starts the server simply refuse to start you can see the following VERY helpful error message in the console.

Unknown error
Compilation failed in require at /usr/share/perl5/Catalyst/Utils.pm line 270.
Compilation failed in require at ./script/stocktrader_server.pl line 55.

You cannot find out where the error occured. Only conclusion that you can make out of this is that there is an error in one of your controllers. Errors in models are shown correctly as they should. Template errors can easily be fixed. If you haven’t been doing incremental development, meaning you add a little bit of code then start the server and see whether everything has worked ok up to now, you’ll be in serious trouble. If you have the habit of writing large amounts of code without testing and keep testing for the last minute, Catalyst will torture you and put you through hellish debugging sessions for hours. I spent an inordinate amount of time trying to figure out the error and finally spotted that I’ve forgotten to make a single variable lexically scoped with my.

I also configured Log4perl to log all the errors to a log file and enabled the option to log warnings. Sadly I could not see any more log messages than I see in the console.

That aside, Catalyst is a fantastic framework to write web applications if you know Perl. As a big fan of frameworks it’s so exciting to see high quality open source MVC frameworks being developed that drastically reduce the effort of building web applications. Whatever the language you’re comfortable in programming, you can easily find a decent MVC framework for it these days. Well .. almost.

Written by Chintana

March 5th, 2009 at 5:46 pm

4 Responses to 'StockTrader client using Catalyst'

Subscribe to comments with RSS or TrackBack to 'StockTrader client using Catalyst'.

  1. Hi.

    The ‘unknown error’ problem is something that plagues Catalyst when running under Perl 5.10, it’s related to 5.10′s attribute handling. We are hoping it will be resolved in 5.10.1

    Marcus Ramberg

    6 Mar 09 at 12:03 pm

  2. @Marcus: Oh … was trying to figure out where exactly Catalyst eats the error messages. Thanks heaps for the explanation!

    Chintana

    6 Mar 09 at 12:21 pm

  3. лучше всего perl 5.8.9

    dima

    17 Mar 10 at 10:41 am

  4. best perl 5.8.9

    dima

    17 Mar 10 at 10:41 am

Leave a Reply