A recent thread got me to start using Error.pm for error handling. I spent about three years coding Java before I started using Perl a lot, so I am familer with the idea behind this kind of exception handling.

Java has Javadocs, which is analgous to POD, except not as flexible and it carries some very Java-specific idioms. One of those specific idioms is documenting exceptions a method can throw (excuse me if this isn't quite right, as I've been away from Java for a while):

/** * Lauch Nuclear Missles. * * @throws LaunchException Failed to launch * @throws ExplodeException Failed to explode */ public void launchNuclearMissles(int megatons) throws LaunchException, ExplodeException { // Code which could throw a LaunchException and // an ExplodeException }

POD doesn't have an equivilent form. What I'm currently thinking of is along these lines:

=head2 launch_nuclear_missles launch_nuclear_missles( $megatons ); THROWS: LaunchException -- Failed to launch ExplodeException -- Failed to explode Launches nuclear missles. =cut

There is no whitespace on the line between the subroutine definition and the THROWS: line, so there will be a logical seperation between them (especially when viewing on search.cpan.org's box-style for fixed-width portions of POD). I'm not sure if this is really the best way to do it, and would like input on other potential methods.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated


In reply to Documenting Thrown Exceptions by hardburn

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.