[3166] 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 (Edith Au)
Thu Nov 2 01:32:56 1995

To: Jonathan Payne <jpayne@starwave.com>
Date: Wed, 1 Nov 1995 23:02:56 -0500 (EST)
From: Edith Au <edith@pencom.com>
Cc: java-interest@java.Eng.Sun.COM
In-Reply-To: <9511011747.AA12100@flim.starwave.com> from "Jonathan Payne" at Nov 1, 95 09:47:59 am

> 
> Would somebody please explain to me when I should make an exception be
> a RuntimeException rather than just an Exception?  

According to the API doc, runtime exception is "An exception that can 
reasonably occur during the execution of a Java program by the Virtual
machine."  For example, NumberFormatException and ArrayIndexOutOfBoundsException
are subclassing from RuntimeException.  It means invalid number format and
arry index out of bounds will cause problem in VM.  So, if you think your
exception can cause problem in VM, make your exception be a RuntimeException.
However, I think Java API already cover most (I wanted to say all but I couldn't
prove it ) of the problems that can happened in VM.  

  Exception is a generic exception.  It can only indicate something abnormal
happened in your program but  you or your caller do not know what goes wrong.
If I am using your class which throws only Exception, I'll be mad at you
because you do not tell me what is the problem and when is the problem occurs.



> Right now I want to
> make everything a RuntimeException because my life is hell.

  I have a feeling you are trying to convert your alpha programs to beta.
Making all exceptions as RuntimeException makes YOUR life easier because
you don't need to declare them in your method definitions and you don't
need to catch them.  However, you are making the life of the people, who
want to use your class, miserable because it will be hard for them to
debug. 

Cheers,
Edith

==============================================================================
Edith Au                            Tel:    (212) 513 7777
WWW Specialist                      Email:  edith@pencom.com
Pencom Systems Incorporated         WWW:    http://www.pencomsi.com/~edith      
40 Fulton Street,
NY, NY 10038
===============================================================================
-
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