This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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

Paweł Baczyński
Bartender

Joined: Apr 18, 2013
Posts: 844
    
  14

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: 5139
    
  12

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: 844
    
  14

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: 5139
    
  12

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