• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IllegalStateException in delete/update

 
Paweł Baczyński
Bartender
Posts: 1799
33
Firefox Browser IntelliJ IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10238
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used IllegalArgumentException and IllegalStateException quite extensively in my application.
 
Paweł Baczyński
Bartender
Posts: 1799
33
Firefox Browser IntelliJ IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10238
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic