[3183] in java-interest

home help back first fref pref prev next nref lref last post

Re: I want to shoot myself!!!!!!!!!!!!!!!!!!

daemon@ATHENA.MIT.EDU (Jonathan Payne)
Thu Nov 2 15:51:40 1995

Date: Thu, 2 Nov 1995 09:15:35 -0800
From: jpayne@starwave.com (Jonathan Payne)
To: mentor@io.org
Cc: Thomas.Ball@Eng.Sun.COM, java-interest@java.Eng.Sun.COM
In-Reply-To: <v01510104acbe0552696a@[204.92.52.11]> (mentor@io.org)

> At 12:18 1/11/95, Jonathan Payne wrote:
> >> From: Thomas.Ball@Eng.Sun.COM (Thomas Ball)
> >>
> >> Basically, there are two groups of errors:  those you can reasonably
> >> recover from and those you can't.
> >
> >...
> >
> >OK, I have a regular expression package.  MalformedRegexpException is
> >thrown when you try compiling an expression that is bogus.  This fits
> >into the category of not-recoverable.  It was a programming error of
> >mine which caused me to generate a bogus regexp string.
> 
>  Not necessarily. What if you read the search string in from the UI? You
> don't want to check the string before passing it off to the regexp package,
> do you? So you pass it in, the parser throws an exception of some sort, and
> you probably do want to catch it in this case.

Right, not necessarily.  But just because you don't have to declare
the exception, it doesn't mean you can't catch it and do something
reasonable with it, like the good old days.  (Actually, I like this
new mechanism, but I was struggling with when something could be a
subclass of RuntimeException.)

An emacs editor would know to catch that exception.  It's part of the
documentation of the class.  But a lot of use of a regular expression
is done in code (at least the way I am using it) and every time I do
that I have to catch or declare the exception even though it's a
literal string in my program.

Whatever.  I think this is a pretty "personal" type issue.  Not
clear-cut either way.

> >OK, how about adding a record to a database. [failure due to mismatched type]
> 
> What if it fails because there's no more space in the DB?

Right.  Or what if the connection goes away.

> >> From: Arthur.Vanhoff@Eng.Sun.COM (Arthur van Hoff)
> >>...
> >> RuntineExceptions should be used only for things that can happen anywhere
> >> regardless of what method you are calling.
> 
> I think both Tom's and Arthur's views are useful, but I think we should be
> careful about which errors are considered recoverable and which not. Much
> depends on context.

Yup.  You can't have it both ways.  I think it's important to remember
that just because you don't have to declare it, it doesn't mean you
(1) won't know about the possibility of its being thrown, or (2)
won't have the ability to catch it.
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post