Best error handling mechanism?

Discussion in 'Perl Misc' started by Rob Hoelz, Jun 5, 2007.

  1. Rob Hoelz

    Rob Hoelz Guest

    I've read numerous articles on the internet, and I haven't come to a
    clear conclusion yet: What form of error handling is best in Perl?
    I've seen try/catch with Error.pm, eval/die with Exception.pm, and just
    plain old eval/die. What's the best way to go about creating a robust
    error handler?

    Thanks,
    Rob
     
    Rob Hoelz, Jun 5, 2007
    #1
    1. Advertising

  2. Rob Hoelz

    -berlin.de Guest

    Rob Hoelz <> wrote in comp.lang.perl.misc:
    > I've read numerous articles on the internet, and I haven't come to a
    > clear conclusion yet: What form of error handling is best in Perl?
    > I've seen try/catch with Error.pm, eval/die with Exception.pm, and just
    > plain old eval/die. What's the best way to go about creating a robust
    > error handler?


    There is no best way.

    You haven't even hinted at what kind of project you need error handling
    for. It takes intimate knowledge about a project and its surrounding
    conditions to make an informed decision about a detail like that.

    There is a chapter (or section) about error handling in _Perl Best
    Practices_ by Damian Conway. I'd take a look at that for general
    points of view. Otherwise, you'll have to do what everybody has to
    do: Evaluate the options, identify their advantages and disadvantages
    in relation to the project and take a pick.

    If that's too tedious (it is tedious) just take a pick and hope for the
    best.

    Anno
     
    -berlin.de, Jun 14, 2007
    #2
    1. Advertising

  3. On Mon, 4 Jun 2007 20:13:12 -0500, Rob Hoelz <> wrote:

    >clear conclusion yet: What form of error handling is best in Perl?


    The best way is not to make errors at all. Corporate policies should
    always include a clause to that effect.


    Michele
    --
    {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
    (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
    ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
    256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
     
    Michele Dondi, Jun 15, 2007
    #3
  4. * Michele Dondi <> wrote:
    >
    > On Mon, 4 Jun 2007 20:13:12 -0500, Rob Hoelz <> wrote:
    >
    >>clear conclusion yet: What form of error handling is best in Perl?

    >
    > The best way is not to make errors at all. Corporate policies should
    > always include a clause to that effect.


    assert($USER_IS_INFALLIBLE, 'Go away!');

    --
    Lars Haugseth

    "If anyone disagrees with anything I say, I am quite prepared not only to
    retract it, but also to deny under oath that I ever said it." -Tom Lehrer
     
    Lars Haugseth, Jun 16, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer
    Replies:
    2
    Views:
    2,189
  2. Ralph A. Moeritz

    exception handling mechanism

    Ralph A. Moeritz, Apr 12, 2005, in forum: C Programming
    Replies:
    1
    Views:
    350
    Fred L. Kleinschmidt
    Apr 12, 2005
  3. Steven Woody

    Event Handling and Signal-Slot Mechanism

    Steven Woody, Jan 19, 2009, in forum: Python
    Replies:
    2
    Views:
    1,099
    Steven Woody
    Jan 20, 2009
  4. Peng Yu
    Replies:
    95
    Views:
    1,551
    Roel Schroeven
    Jan 7, 2010
  5. Don Y
    Replies:
    87
    Views:
    1,032
    Don Y
    Mar 9, 2012
Loading...

Share This Page