All OO in Perl is done through packages. As all the errors in the Error paradigm are objects, you're going to have to use packages. *shrugs*

Personally, most of my packages look like:

package MyErrors::SomeError; use Error::Simple; @ISA = qw(Error::Simple); 1;

(Yes, I know there's no strict, warnings, or whatever. With something this simple, I tend to skip those things.)

Then, when you want to use it, you can just catch that error.

The really neat thing about doing this is that you can create classes of errors. Let's say you have 10 errors that can arise from a database action. Instead of having to handle each one, you can have a base class of MyError::Database and have all your DB errors use it as the base class. MyError::Database would inherit from Error::Simple, thus allowing you to handle all your errors in one place, if you wanted.

That kind of hierarchy is one of the huge benefits of OO, allowing you to specify where in the hierarchy you want to work in.

------
We are the carpenters and bricklayers of the Information Age.

The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.


In reply to Re5: Error module by dragonchild
in thread Error module by hotshot

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.