[Koha-patches] [PATCH 2/2] Bug 5415 Let calls of SimpleSearch utilize considtent interface

Clay Fouts cfouts at liblime.com
Thu Nov 18 17:37:15 CET 2010


The die() in the above code is perfectly legitimate because the routine does
not know how to handle the error gracefully. I cannot count the number of
hours I've had to spend tracking a bug back to its source through all sorts
of twists and turns because Koha did not die() when it couldn't figure out
how to handle the original error and simply warn()ed about it or, more
frequently, opted not to check for errors at all.

The good thing about exceptions is that you cannot ignore the error and get
away with it. Warn()s can and do get ignored, much to the detriment of
developers, users, and everyone in between. Every best practices guide will
tell you to die() as soon as you figure out that you can't accommodate the
nature of the error, precisely because it is ugly and cannot be ignored,
forcing the developer to handle it somehow at a higher level. Programmers
are lazy. Unless we compel ourselves to address errors, it's far too easy to
ignore them, so we will (and do, if Koha's code is to serve as an example).
Exceptions demand better coding practicing.

Koha already has a CGI-friendly die() handler with CGI::Carp. If how it is
presented to the user is a concern, the template for that can be prettified.
Nevertheless, it's a favor to everyone not to let errors propagate
throughout the system. It corrupts data and gives the false perception that
everything is behaving correctly.

Cheers,
Clay


On Thu, Nov 18, 2010 at 4:42 AM, Chris Nighswonger <
cnighswonger at foundations.edu> wrote:

> On Thu, Nov 18, 2010 at 4:56 AM, LAURENT Henri-Damien
> <henridamien.laurent at biblibre.com> wrote:
> > Hi Colin.
> > I have seen that you are using die....
> > There has already been a discussion on that on list.
> > No concensus achieved.
> > But I find it really clunky to have that kind of warning for users :
> > Koha Software error....
> >
> > I acknowledge that a warning has to be raised.
> > Maybe dying is really good practise. But Having more failproof features
> > would be far more comfortable for users (and developers)... When seeing
> > Software error, they will undoubtedly open a new bug... on bugzilla,
> > which is already a bit crowded.
> > Your aim here is surely to HAVE problems reported rather than "hidden"
> > in logs file.
> > But I would have rather, when it is not really a blocking problem, just
> > try and raise a warning.
> >
> > If dying is really a requirement in Modern::Perl then it HAS to be
> > handled in the pl script. And I donot think it is done. Gentlemen ?
> > Can we reach a good practise ?
>
> I am in 100% agreement that we should not die, but rather throw a warn
> to the log and then trap the error, passing useful information back to
> the user and allowing graceful recovery. I can conceive of no problem
> which should not be able to be properly trapped and an error message
> passed back to the user. Even if it is a "blocking problem," graceful
> recovery and or exit is a necessity. With bugzilla accepting emails it
> may even be within the realm of possibility to have something like
> C4::ErrorHandling do automatic bug reporting or the like.
>
> I object to adding new code which just dies rather than handling the error.
>
> Kind Regards,
> Chris
> _______________________________________________
> Koha-patches mailing list
> Koha-patches at lists.koha-community.org
> http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
> website : http://www.koha-community.org/
> git : http://git.koha-community.org/
> bugs : http://bugs.koha-community.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-patches/attachments/20101118/66bcdaba/attachment.htm>


More information about the Koha-patches mailing list