Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Re: Advantages of OO-ish exception handling..

by impossiblerobot (Deacon)
on Dec 22, 2001 at 09:57 UTC ( [id://133944]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Advantages of OO-ish exception handling..
in thread Advantages of OO-ish exception handling..

If I understand this right, I could throw a generic exception-type (possibly even the top-level exception class?) and thereby pass the exception-handling up the class hierarchy. Is that a fair re-statement?

I suppose this is not the place for a Java lesson (though it looks like I need one). But it does help me start to see how this type of structure might be useful in Perl.

(It still seems like a lot of hoops to jump through if this is the only benefit.)

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

Replies are listed 'Best First'.
Re: Re: Re: Re: Advantages of OO-ish exception handling..
by Masem (Monsignor) on Dec 22, 2001 at 18:35 UTC
    You *could*, but that's not good programming practice (That is, you simply have all your functions declared as throwing generic Exceptions. The Java Exception model is designed that as your classes become more specialized, the types of exceptions they throw should also become more specialized. The only place were you should catch the base class of all exceptions, Exception, is in the main() body of the code or in the JApplet/JApplication object.

    Note that you cannot throw a more generic exception type than your function/method allows. If FileException ISA IOException ISA Exception, then a function that defined itself to throw an IOException will be happy as long as only FileExceptions or IOExceptions are thrown, but will complain (AT COMPILE TIME, since the exception mechanism is that detailed) if you throw a generic Exception.

    -----------------------------------------------------
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
    "I can see my house from here!"
    It's not what you know, but knowing how to find it if you don't know that's important

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://133944]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-19 20:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found