in reply to Advantages of OO-ish exception handling..

Inheritance. You can then test for the type of exception caught using isa (or its equivalent in whichever language you're using). This way, you can partition the set of possible exceptions into useful subsets, and deal with each subset individually.

  • Comment on Re: Advantages of OO-ish exception handling..

Replies are listed 'Best First'.
Re: Re: Advantages of OO-ish exception handling..
by vladb (Vicar) on Dec 22, 2001 at 12:23 UTC
    Precisely!

    And on top of it, you can do it at verious stages of your execution (aka layers). Some errors may have to be dealt with in lower levels (nearer to, says, system 'layer') and thus not visible to upper layers that shouldn't really be concerned with certain details.

    isa() calls is certainly a great way to approach this. It is also much more clearer than dealing with static die strings ($@). Certainly, static strings, by their nature, do not allow for the complexity (i should rather say, flexibility) that OO offers.

    On the other hand, it may be more justifiable to actually not use OO-ish excpetion handling methods in simple code and therefore avoid going through the 'extra hoops' in order to yield no noticable reward.



    "There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith