This is not a functionality issue but a language issue.

It's not a language or a functionality issue. It's a development team issue. In any project it will be best to pick a common error handling mechanism. This is true no matter what language you choose.

If you have multiple people on a team using different coding styles that's a team problem, not a language problem.

Beyond that it's not really an issue. It's trivial to wrap code that handles errors via return values so that it throws exceptions (e.g. Fatal). It's trivial to wrap code that throws exceptions to return errors (via eval {}).

Personally I would recommend using exceptions since I find they have many advantages. However, this is an issue for your development team to decide after weighing the pros and cons.

Exceptions are also completely separate from OO. You can, if you wish, have an exception handling system with just plain strings (although I wouldn't recommend it).

The try/catch syntax supplied by Error has some problems as perrin has already pointed out. However this has to do with prototyping/blocks/closures rather than exception handling in Perl. All the other modules do is provide some syntactic sugar for declaring exception classes and throwing exception objects.

There is nothing special about these classes and objects - they're just normal Perl objects. Exception handling is a core part of Perl and you shouldn't worry about using it if it's appropriate for your project. For many kinds of Perl applications (e.g. DBI) exceptions are really the only way to go.


In reply to Re^2: Be more OO with "Class" modules? by adrianh
in thread Be more OO with "Class" modules? by chunlou

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.