Subject: | Feature request predefine messages |
Date: | Mon, 30 Jun 2008 20:24:08 +0200 |
To: | bug-exception-class [...] rt.cpan.org |
From: | Lutz Gehlen <perl [...] lutzgehlen.de> |
Dear Dave,
thank you for developing the Exception::Class module. I hope it's
fine to also send feature requests to this email address.
Although with Exception::Class it becomes less important to keep
track of the actual strings that you use for an error message I
still like to keep also the concrete messages at some central place
either at the beginning of a class or even in a central exception
module. Additionally, I like the code to actually throw the
exception to be as short as possible, preferably fitting into one
line which is rather unlikely if the call includes the actual
message.
Therefore I started to develop a module that allows you to easily
define functions that are put into your namespace and throw a given
Exception::Class::Base (or subclass) object with a given message
text. Although I had thought about that before I got now - while
discussing a good name space on the module authors mailing list - a
new idea how this behaviour could fit into Exception::Class itself.
Therefore I decided to ask you if you would be interested in
integrating something like this into Exception::Class.
I attach a patch (lines 170-189 in Class.pm) and a small proof of
concept test. The patch introduces a messages parameter that can be
given to 'import' and contains a hash reference with names for the
subroutines and error message templates. The tests should run if you
cd to Exception-Class and call perl -T -Ilib t/messages .
Thanks for your feedback,
Lutz
Message body not shown because it is not plain text.