The conventional technique of returning error status from the called routine depends on the calling code to manage any error condition and possibly to pass the problem up the calling chain. That process relies on the writer of the calling code to correctly supply error handling code at every point in the calling chain. This of course depends on the programmer being aware that the error handling code needs to be supplied and interested enough to supply it. It also requires that the code context be appropriate for handling the error, which often may not be the case (inside a module for example).

Using exceptions for error handling turns all that around. Code that can't handle errors or doesn't care simply does nothing. If nothing cares, the error gets handled by escaping all the way out to the $SIG{DIE} handler. At that point the programmer may start to care enough to take notice and do something about error handling. ;)

Oh, and none of this is really any different for OO or procedural styles of programming.


True laziness is hard work

In reply to Re: Advantage of Exception handling in perl by GrandFather
in thread Advantage of Exception handling in perl by vinoth.ree

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.