0

I try to create a base RuntimeException class:

BaseRuntimeException extends RuntimeException 

with some additional functionality such as i18n. From that base class I want to create one class per type of RuntimeException. For ex.,

public class SetterWithNullPointerException extends BaseRuntimeException

However, I am getting this compile error wherever I throw a SetterWithNullPointerException

Unhandled exception type SetterWithNullPointerException 

It is like by not having RuntimeException being the direct superclass of SetterWithNullPointerException, I lose the unchecked exception properties of RuntimeException. (Easily checked if I make SetterWithNullPointerException inherit directly from RuntimeExeption)

My question is... is there anyway around this? Do I have to make something special on BaseRuntimeExceptionto make its children inherit the unchecked exception properties?

Thanks a lot! Manu

manubot
  • 290
  • 2
  • 19

1 Answers1

0

I am sorry for all the noise. The comments under this answer are correct. There was nothing wrong on what I was doing. You can extend as many times as you want RuntimeException.

My IDE must have played a trick on me. Where there were compiler errors before, there are none now. Kids, before coming to SO, do a "Project Clean" when you think the errors you are seeing don't make any sense...

Apologies again.

manubot
  • 290
  • 2
  • 19
  • 2
    That wouldn't cause this problem. The compiler already does that automatically. – user207421 Oct 08 '13 at 10:14
  • I swear that if I comment those two constructors I get the compile error mentioned in the OP on every part of the code where I do: throw new SetterWithNullPointerException() – manubot Oct 08 '13 at 10:20
  • @EJP Is it possible that it is a problem, that he made `BaseRuntimeException` abstract? - EDIT: Nope, just tried that. – Fildor Oct 08 '13 at 11:18
  • 1
    @manubot I just set up a little project, that has nothing more than 2 Exception classes, one abstract extending RuntimeException and the other extending the first. Complete empty class bodies, both. Could instanciate and throw the latter without any compiler error. – Fildor Oct 08 '13 at 11:23