Thanks for the feedback... and just to clarify, when it comes to tailoring errors I am not actually adding code within the MessageLibrary class itself, but specifying it in the object constructors, something like this:

my $error_messages = MessageLibrary->new({ file_open_error => sub{"Couldn't open $_[0]: $!"}, bad_token => sub{"Invalid token $_[0] encountered on line $_[1]"}, bad_file_format => "Invalid file format", }); my $status_messages = MessageLibrary->new({ starting_parse_phase => "Starting parser...", generating_results => sub {"Generating results for element $_[0]"}, });
So basically the only stuff in the class package is just a constructor, an AUTOLOAD method, and a couple of little utility methods.

Update: While rereading this response, I realized there was an aspect of jeffa's point about not having to tailor error messages that I only partially answered. Although you can define error messages in the object constructor, the object also provides default handling for any method you might call. So you could do this: print $status_messages->undefined_msg($a_param, $another); and get a reasonable result. (You can also override this default behavior in the object constructor.)


In reply to Re: (jeffa) Re: is this a perversion of OO principles? by seattlejohn
in thread is this a perversion of OO principles? by seattlejohn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.