• Post Reply Bookmark Topic Watch Topic
  • New Topic

Validation check for Exception messages  RSS feed

 
Rajeev Srikhar
Ranch Hand
Posts: 75
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below code shows my custom runtime exception.


Here I want to know how to validate the message 's' in the constructor. I can't do a validation check like below as constructor's first statement should be super.


Should I use methods or let me know how to do validation check for the Exception Input message.
 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What should happen if s is null?
 
Rajeev Srikhar
Ranch Hand
Posts: 75
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually , I'm supposed to validate each and every Input data(even the Exception) in my project.
But now I'm trying to use Pluggable Exception handlers for doing that.

 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Copy first, validate afterwards. Since Strings are immutable, there is no need for any copying.I do not think you can copy Exceptions, because they don't have copy constructors nor copying methods.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajeev Pedada wrote:Here I want to know how to validate the message 's' in the constructor. I can't do a validation check like below as constructor's first statement should be super.

Not completely true - you can call static methods inside the super call:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!