Error.pm and try/catch/throw

Discussion in 'Perl Misc' started by fishfry, Jul 21, 2005.

  1. fishfry

    fishfry Guest

    Is Error.pm the standard way to do error handling these days? Or at
    least *a* standard way?

    Are there any standard or popular libraries of exceptions, or should I
    just write my own Error.pm subclasses?
    fishfry, Jul 21, 2005
    #1
    1. Advertising

  2. fishfry

    fishfry Guest

    In article
    <>,
    fishfry <> wrote:

    > Is Error.pm the standard way to do error handling these days? Or at
    > least *a* standard way?
    >
    > Are there any standard or popular libraries of exceptions, or should I
    > just write my own Error.pm subclasses?


    No responses? I was just curious to know what kind of error handling
    people do. It seems to me that the try/catch/throw method is an
    improvement to the old days of checking error returns and trying to pass
    the right amount of error detail info upstairs to callers. I know how to
    use eval and die handlers.

    Do most serious Perl programmers use one method or another of handling
    errors, and if so, what?
    fishfry, Jul 22, 2005
    #2
    1. Advertising

  3. fishfry

    SMO Guest

    fishfry wrote:
    > In article
    > <>,
    > fishfry <> wrote:
    >
    >
    >>Is Error.pm the standard way to do error handling these days? Or at
    >>least *a* standard way?
    >>
    >>Are there any standard or popular libraries of exceptions, or should I
    >>just write my own Error.pm subclasses?

    >
    >
    > No responses? I was just curious to know what kind of error handling
    > people do. It seems to me that the try/catch/throw method is an
    > improvement to the old days of checking error returns and trying to pass
    > the right amount of error detail info upstairs to callers. I know how to
    > use eval and die handlers.
    >
    > Do most serious Perl programmers use one method or another of handling
    > errors, and if so, what?


    FWIW I use try/catch/throw exception handling via a custom wrapping of
    Error.pm

    MS
    SMO, Jul 22, 2005
    #3
  4. fishfry <> wrote:


    > No responses?



    Maybe potential responders have decided to keep their attitude to
    themselves, as you have requested in the past?


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Jul 22, 2005
    #4
  5. On Thu, 21 Jul 2005 19:08:50 -0700, fishfry wrote:

    > In article
    > <>,
    > fishfry <> wrote:
    >
    >> Is Error.pm the standard way to do error handling these days? Or at
    >> least *a* standard way?
    >>
    >> Are there any standard or popular libraries of exceptions, or should I
    >> just write my own Error.pm subclasses?

    >
    > No responses? I was just curious to know what kind of error handling
    > people do. It seems to me that the try/catch/throw method is an
    > improvement to the old days of checking error returns and trying to pass
    > the right amount of error detail info upstairs to callers. I know how to
    > use eval and die handlers.
    >
    > Do most serious Perl programmers use one method or another of handling
    > errors, and if so, what?


    I use eval and a custom error object. The main problem I have with this is
    that the eval is at the top level and so any module error messages which
    don't provide a line number in the caller (as is the case with
    DBD::Sybase) can be difficult to trace. Otherwise it works well. I define
    some error codes in my Error object and trapping specific errors can be as
    simple as

    die MyApp::Error->new(<errorcode>) unless (...);

    Also unforseen errors get trapped by the eval. $@ is a string not an
    object when that happens, but is easily remedied.

    Rich

    --
    "...Then anyone who leaves behind him a written manual, and likewise
    anyone who receives it, in the belief that such writing will be clear and
    certain, must be exceedingly simple-minded..."
    -- Plato, _Phaedrus_
    Richard Gration, Jul 22, 2005
    #5
  6. fishfry

    fishfry Guest

    In article <>,
    Tad McClellan <> wrote:

    > fishfry <> wrote:
    >
    >
    > > No responses?

    >
    >
    > Maybe potential responders have decided to keep their attitude to
    > themselves, as you have requested in the past?


    Thanks Tad.
    fishfry, Jul 22, 2005
    #6
  7. fishfry

    Ron Savage Guest

    On Thu, 21 Jul 2005 15:54:02 +1000, fishfry wrote:

    Hi Fishy

    If you search the archives of (I think) mod_perl's mailing list you'll seeError
    has been repeatedly criticised. The alternative recommended isException::Class.
    Ron Savage, Jul 24, 2005
    #7
    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. Jon Maz
    Replies:
    7
    Views:
    4,273
    Jon Maz
    Oct 25, 2004
  2. Matt
    Replies:
    1
    Views:
    406
    Michael Rauscher
    Jun 12, 2004
  3. Chris Riesbeck

    try-catch-throw-finally

    Chris Riesbeck, Jan 19, 2007, in forum: Java
    Replies:
    3
    Views:
    1,030
    Chris Riesbeck
    Jan 22, 2007
  4. Replies:
    8
    Views:
    347
    Matteo
    Dec 5, 2005
  5. dick

    "try{throw}catch"

    dick, Nov 15, 2006, in forum: C++
    Replies:
    7
    Views:
    405
    Noah Roberts
    Nov 15, 2006
Loading...

Share This Page