GeeCON Prague 2014*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes IllegalStateException in delete/update Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "IllegalStateException in delete/update" Watch "IllegalStateException in delete/update" New topic
Author

IllegalStateException in delete/update

Paweł Baczyński
Bartender

Joined: Apr 18, 2013
Posts: 1012
    
  16

Is it a good idea to throw IllegalStateException from delete and update methods when invoked on an unlocked record?
The interface doesn't mention this exception. But... ISE is an unchecked exception so it doesn't need to me mentioned.
What do you think?


Formely Pawel Pawlowicz
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5299
    
  13

I used IllegalArgumentException and IllegalStateException quite extensively in my application.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Paweł Baczyński
Bartender

Joined: Apr 18, 2013
Posts: 1012
    
  16

Suppose null was passed to createRecord(String[] record)
Which is better? NullPointerException or InvalidArgumentException?
I'd use InvalidArgumentException because it is more specific.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5299
    
  13

I used IllegalArgumentException for that purpose. But the Java classes (like String) uses NullPointerException: Unless otherwise noted, passing a null argument to a constructor or method in this class will cause a NullPointerException to be thrown.
 
GeeCON Prague 2014
 
subject: IllegalStateException in delete/update