aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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

Pawel Pawlowicz
Ranch Hand

Joined: Apr 18, 2013
Posts: 607
    
  11

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?
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4926
    
  10

I used IllegalArgumentException and IllegalStateException quite extensively in my application.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Pawel Pawlowicz
Ranch Hand

Joined: Apr 18, 2013
Posts: 607
    
  11

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: 4926
    
  10

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.
 
wood burning stoves
 
subject: IllegalStateException in delete/update
 
Similar Threads
Do I need to catch any of these exception in my code ?
Problem with unlock method with wrong lockCookie
Why throw an RecordNotFoundException in your unlock method?
[B&S] - Delete & Unlock Questions
SecurityException