Koha Day - CGI::Carp error handling
Hi Koha-Devel, There has been a little talk recently on the koha-devel list about error handling in Koha. Chris and I spent some time on Friday(nz time) to work out a relatively small and tidy way, using CGI::Carp, to trap and redirect most runtime errors in Koha to the user's browser. We have made a System-Preference called DebugLevel, that has currently 3 values 0, 1 and 2. (more?) something like... ??? 0 is Quiet - For production 1 is Developer - For debugging 2 is Logging - Bug reporting , and additional package version info too, like Apache, MySQL, Perl,YAZ, Z9350::ZOOM MARC::Record/Charset.... The CGI::Carp stuff has been added near the start of Output.pm, so it's set up nice and early to handle (and output) any later errors. I committed the CGI::Carp stuff to dev_week, but if people like the idea, I'll commit it to rel_3 too... Here is the commit to Output.pm below. http://cvs.savannah.nongnu.org/viewvc/koha/C4/Output.pm? root=koha&r1=1.51.2.2.2.1&r2=1.51.2.2.2.2&pathrev=dev_week Using CGI::Carp with the DebugLevel syspref at '2', Koha now handles this example script's syntax error. ---------------------------------- #!/usr/bin/perl use C4::Output; ndjsnsjkcndjkscndjskcndjks exit; ------------------------------------ And sends Perl's error message back to he user's browser for either debugging further, or perhaps attaching to a bug report, or to the bottom of a koha-devel list email. Like this below.... ---------------------------------- debug level 2 Got an error: syntax error at /koha/dev_week/intranet/cgi-bin/misc/ carp_test.pl line 6, near "ndjsnsjkcndjkscndjskcndjks exit" Execution of /koha/dev_week/intranet/cgi-bin/misc/carp_test.pl aborted due to compilation errors. Koha 2.2.8 Perl 5.008008 MySQL mysql Ver 14.12 Distrib 5.0.32, for pc-linux-gnu (i486) using readline 5.2 OS Linux arwen.metavore.com 2.6.18-4-686 #1 SMP Mon Mar 26 17:17:36 UTC 2007 i686 GNU/Linux Apache Server version: Apache/2.2.3 Server built: Jun 17 2007 20:24:06 ---------------------------------- How does this sound, Any improvements suggestions or corrections? Cheers, Mason -- Mason James mason.james@liblime.com Programmer www.liblime.com LibLime +64 21 542 117
Mason James wrote:
The CGI::Carp stuff has been added near the start of Output.pm, so it's set up nice and early to handle (and output) any later errors. I committed the CGI::Carp stuff to dev_week, but if people like the idea, I'll commit it to rel_3 too... [SNIP] ----------------------------------
How does this sound, Any improvements suggestions or corrections?
Sounds great. This should go a long way towards finding out the causes of errors, especially during installation and initial testing. Is Output.pm used by all scripts? cheers rickw -- _________________________________ Rick Welykochy || Praxis Services Traditionally, most of Australia's imports come from overseas. -- Keppel Enderbery
Mason James <mtj@liblime.com> wrote:
The CGI::Carp stuff has been added near the start of Output.pm, so it's set up nice and early to handle (and output) any later errors. I committed the CGI::Carp stuff to dev_week, but if people like the idea, I'll commit it to rel_3 too...
I wonder whether Output is the best place for this, or whether it should be loaded in Context too if possible, which many scripts load first and may encounter database- or config-related problems IIRC. Can this be committed to git, please? Thanks, -- MJ Ray http://mjr.towers.org.uk/email.html tel:+844-4437-237 - Webmaster-developer, statistician, sysadmin, online shop builder, consumer and workers co-operative member http://www.ttllp.co.uk/ - Writing on koha, debian, sat TV, Kewstoke http://mjr.towers.org.uk/
On 24/09/2007, at 6:26 PM, MJ Ray wrote:
Mason James <mtj@liblime.com> wrote:
The CGI::Carp stuff has been added near the start of Output.pm, so it's set up nice and early to handle (and output) any later errors. I committed the CGI::Carp stuff to dev_week, but if people like the idea, I'll commit it to rel_3 too...
I wonder whether Output is the best place for this, or whether it should be loaded in Context too if possible, which many scripts load first and may encounter database- or config-related problems IIRC.
Can this be committed to git, please?
Hiya MJR, Yes, Context.pm was my first choice too :) I just did a search thru the koha3 code... and Context.pm is called 337 times, compared to Output.pm's 279 times So i think Context.pm wins. Ill test and commit this to koha3 git tomorrow Cheers, Mason -- Mason James mason.james@liblime.com Programmer www.liblime.com LibLime +64 21 542 117
Can this be committed to git, please?
Ill test and commit this to koha3 git tomorrow
Hi Everyone, The CGI::Carp error handling stuff has been committed to koha3 git. We thought a nice future feature to the CGI::Carp stuff would be to add sysprefs for: a SMTP server, and a 'koha-error-reports' email-address syspref. With this extra info, we can now start automating the sending of Koha runtime errors to an email address. (or give the user the option of sending an error-report from their browser). This extra info should be handy for users, admin and developers alike. And will make future errors more visible, and 'empower' everyone with more info to nag, and fix these errors. MJ Ray, how do the updater/installer commits look to you? FYI: The commit diffs are here http://git.koha.org/cgi-bin/gitweb.cgi?p=Koha;a=blobdiff;f=C4/ Context.pm;h=15a09d5e1ddb205f878f2fa390c5b1bcfc6169a3;hp=7661a5723e4eede 1776b8e1e3baf3bee23495ba9;hb=e4963322557f7dfda080e401a5dbcfcc22684020;hp b=948f8c0640ae2fe79d6b2bf493ac6ae839884920 http://git.koha.org/cgi-bin/gitweb.cgi?p=Koha;a=blobdiff;f=admin/ systempreferences.pl;h=37e988e4edc6169d1fab2bac076580b8e8c4aefc;hp=4489b 183b98ba41b86c2c7aabbad99021a576666;hb=6bd75d133fe2a693a5e832d2fbd69d892 975e449;hpb=e4963322557f7dfda080e401a5dbcfcc22684020 http://git.koha.org/cgi-bin/gitweb.cgi?p=Koha;a=blobdiff;f=updater/ updatedatabase;h=eab08cfdad409ea8b25d305d003296ba963646e0;hp=98ccdeef135 83bdf2cbc72b84e2fbef67c342959;hb=fa0d39a1f97fc5804dcbe5d22756d52b1c0777a 6;hpb=6bd75d133fe2a693a5e832d2fbd69d892975e449 http://git.koha.org/cgi-bin/gitweb.cgi?p=Koha;a=blobdiff;f=installer/ data/en/mandatory/ sysprefs.sql;h=89d504faeb3bc38b37d98fef894fd55c0d2d0941;hp=48f9b8a51efac 3f977db1e2be4e7b6f788eaf5dd;hb=64a5e75384275d0b2a8e75b18466d12697bee706; hpb=fa0d39a1f97fc5804dcbe5d22756d52b1c0777a6 Any comments? Rick? Cheers, Mason -- Mason James mason.james@liblime.com Programmer www.liblime.com LibLime +64 21 542 117
Mason James <mtj@liblime.com> wrote:
MJ Ray, how do the updater/installer commits look to you? [...] http://git.koha.org/cgi-bin/gitweb.cgi?p=Koha;a=blobdiff;f=updater/ updatedatabase;h=eab08cfdad409ea8b25d305d003296ba963646e0;hp=98ccdeef135 83bdf2cbc72b84e2fbef67c342959;hb=fa0d39a1f97fc5804dcbe5d22756d52b1c0777a 6;hpb=6bd75d133fe2a693a5e832d2fbd69d892975e449
http://git.koha.org/cgi-bin/gitweb.cgi?p=Koha;a=blobdiff;f=installer/ data/en/mandatory/ sysprefs.sql;h=89d504faeb3bc38b37d98fef894fd55c0d2d0941;hp=48f9b8a51efac 3f977db1e2be4e7b6f788eaf5dd;hb=64a5e75384275d0b2a8e75b18466d12697bee706; hpb=fa0d39a1f97fc5804dcbe5d22756d52b1c0777a6
The installer commit looks fine, but I don't understand why it's indented. I'm ignoring the updater - it should be replaced by SQL. ;-) Regards, -- MJ Ray http://mjr.towers.org.uk/email.html tel:+44-844-4437-237 - Webmaster-developer, statistician, sysadmin, online shop builder, consumer and workers co-operative member http://www.ttllp.co.uk/ - Writing on koha, debian, sat TV, Kewstoke http://mjr.towers.org.uk/
participants (3)
-
Mason James -
MJ Ray -
Rick Welykochy