hardburn has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Documenting Thrown Exceptions
by PodMaster (Abbot) on Jul 11, 2003 at 18:26 UTC | |
by halley (Prior) on Jul 11, 2003 at 18:50 UTC | |
|
Re: Documenting Thrown Exceptions
by adrianh (Chancellor) on Jul 11, 2003 at 18:19 UTC | |
|
Re: Documenting Thrown Exceptions
by lachoy (Parson) on Jul 11, 2003 at 18:31 UTC |