This is not so much a reply, as it is an opinionated appendix.

That's not all Error has to offer though. I use it, so far trying and catching nearly only in tests. I might use try/catch in the future, but so far the implementation of it as an exception object has been pretty useful without the error handling per se.

The reason I like exception objects is that they promote machine recognizable errors, and thus make error handling/reporting easier.

Firstly, each error has a class. You can represent groups of errors rather easily with inheritence.

A certain type of error could inherit from the pseudoclass Error::Recoverable, for example, to allow code catching it to re-attempt the errorneus code. Error categories, for the sake of clean reporting are also nice.

Another feature of error objects is that they are compound. In my errors, the string is just for the user. I have a unique code for each error (generated by a constant allocator). This is more deterministic than matching regexes on error strings.

Now, with all this, and the fact that Error is still outwardly compatible with string errors, since the objects stringify, I see no reason why not to promote at least partial use of the Error module.

-nuffin
zz zZ Z Z #!perl

In reply to Re^2: Prototype "foo {...} bar {...}" is documented? by nothingmuch
in thread Prototype "foo {...} bar {...}" is documented? by gmpassos

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.