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: 1275
    
  18

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?


OCPJP 6, 7, 8, OCMJD 6
Roel De Nijs
Sheriff

Joined: Jul 19, 2004
Posts: 7251
    
  29

I used IllegalArgumentException and IllegalStateException quite extensively in my application.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
OCAJP 7
Paweł Baczyński
Bartender

Joined: Apr 18, 2013
Posts: 1275
    
  18

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
Sheriff

Joined: Jul 19, 2004
Posts: 7251
    
  29

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IllegalStateException in delete/update
 
It's not a secret anymore!