Path: news.cs.au.dk!not-for-mail From: John Cowan Newsgroups: comp.lang.beta Subject: Re: Static vs. dynamic exceptions Date: 21 Jun 2000 16:59:38 -0000 Organization: Reuters Health Information Lines: 42 Approved: mailtonews@cs.au.dk Distribution: world Message-ID: <20000621165938.19086.qmail@noatun.mjolner.dk> Reply-To: John Cowan NNTP-Posting-Host: daimi.cs.au.dk X-Trace: xinwen.cs.au.dk 961606799 368080 255.255.255.255 (21 Jun 2000 16:59:59 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 21 Jun 2000 16:59:59 GMT Xref: news.cs.au.dk comp.lang.beta:12480 "Jørgen Lindskov Knudsen" wrote: > Well, the Java model is actually _not_ as you describe it. All Java > exceptions who interit from the Throwable class follow the rule above. > However, all other exceptions (e.g. numerical exceptions) does _not_ follow > this rule - i.e. that are _not_ declares in the interface, and can be thrown > through any number of message invocations. Almost. All errors and exceptions whatever inherit from Throwable. The class tree below Throwable is (in part): Throwable Error Exception RuntimeException Semantically, errors (subclasses of Error) represent events that typically should *not* be caught: they represent programming errors. Exceptions can and should be caught; of those, RuntimeExceptions are those (attempt to send a method to null, floating-point exception, illegal array access, etc.) that could occur at almost any point in the code. Therefore, throwables that inherit from either Error or RuntimeException need not be declared in method headers. All other exceptions must be declared; a method that might throw an exception (either directly in a throw statement, or by way of calling a method that is declared to throw the exception) must either handle the exception or declare it in the method header. > However, the Java model makes the distinction between an error and a fault > based on the _type_ of the exception. I really do not believe in that model > (making it impossible to automatically convert an error situation into a > fault). Automatically, no. However, it is possible to catch all Exceptions and wrap them in Error objects. -- Schlingt dreifach einen Kreis um dies! || John Cowan Schliesst euer Aug vor heiliger Schau, || http://www.reutershealth.com Denn er genoss vom Honig-Tau, || http://www.ccil.org/~cowan Und trank die Milch vom Paradies. -- Coleridge (tr. Politzer)