Why not RuntimeExceptions?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Joao Guilherme Del Valle

Why not RuntimeExceptions?

Post by Joao Guilherme Del Valle » Thu Nov 29, 2001 10:20 pm

Hi,

Migrating my project to version 0.6.0, I found that there are two exceptions being thrown in a code piece that needs to be made almost everytime. Like this:

DefaultCategoryDataset ds = new DefaultCategoryDataset(series, data );
JFreeChart chart = new JFreeChart( ds, new PiePlot() );

Here I have to catch two exceptions: AxisNotCompatibleException and PlotNotCompatibleException, thown by the "new PiePlot()" instruction. This can´t be, the client developer has to work more this way. These two are typical RuntimeExceptions, that don´t need to be explicitly caught. They are not data input exceptions but programming exceptions, so the first time the prog runs, the programmer will notice any mistake, because the exception will be throw like a RuntimeException, that is normally caught in some highest level. It´s not normal to happen.
A try/catch here would serve only for the programmer tell himself that he´s doing something wrong, that like this the code will never work, and this is not for what a non-RuntimeException is planned, it´s expected exceptions.

I would suggest that you turn these into RuntimeExceptions. What do you think about that?

Thank you,
Joao.

David Gilbert

RE: Why not RuntimeExceptions?

Post by David Gilbert » Fri Nov 30, 2001 10:06 am

Hi Joao,

Thanks for your feedback. I can't fault your reasoning. Unless anyone else has anything to add, I'll change these exceptions for the next release (0.6.1).

Regards,

DG.

Locked