• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it dvisable to throw exceptions inside the setter mehods ?

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it dvisable to throw exceptions inside the setter mehods ?

For example :



Thanks in advance.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Good idea.

But you should be circumspect about what sort of Exception you are throwing. I would enhance what you have written toNote that much of what I wrote is actually documentation comments, so users of that method know about the Exception.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic