develooper Front page | perl.perl5.porters | Postings from September 2006

Error messages in perl, no central definitions? Localization not possible, maintenance hard....

Thread Next
From:
demerphq
Date:
September 29, 2006 00:20
Subject:
Error messages in perl, no central definitions? Localization not possible, maintenance hard....
Message ID:
9b18b3110609290019y3e9a6cf8j8729b1532eb66c45@mail.gmail.com
I noticed yesterday that we dont have a central point where we define
the error messages generated by perl. Which means that if one wants to
change a given error message one must trawl the sources for all the
places where given DIE/CROAK is used.

I think it would be a good idea to migrate all of the perl error
messages into a module.  I also think it would be a good idea to
define error codes for perl to use. Thus

DIE(aTHX_ "Not a GLOB reference");

would become something like

THROW_ERROR(PERL_ERROR_NOT_GLOB_REF);

The advantage would be that maintenance would be easier. If a given
message is to be changed it can be changed in a single place.
Furthermore this would allow commercial vendors (like that team that
did the zOS port) to replace the messages with their own framework if
they felt they needed to, and lastly it would/should allow localized
error messages. Im sure our non english speaking user base would
appreciate error messages in their own language.

A possible impact of supporting localized error messages is that code
that is written to test for a given error message will break. And
rightly so, doing string comparisons (even if you have a sweet regex
engine to make it easier) on error messages is a kludgy solution. The
solution IMO is to add an error code value to the message. The error
code would provide a localization agnostic means to identify a given
error.

So the "Not a GLOB reference" would turn into something like

"PerlError-001: Not a GLOB reference"

I'm curious what people think of this. But bear in mind we are talking
about changes to a major release of Perl where there already have been
signifigant changes to the error messages. Breaking code due to error
changes is a given for 5.10, so please dont just dismiss the idea
outright in order to please the hysterical porpoises, they are going
to be pissed regardless.

Yves



-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About