File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception object catching multiple exceptions in one time?

 
siddhu Math
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

I have an XML with Three nodes in it say name, last name, salary now i need to do validation on the same. Assume some validation and there results an error for all three nodes(different) now i want to throw one single error stack (custom error ) logging all the three issues of why it failed say (1) name is not currect 2) last name is not correct 3) salary is not currect). is this achivable in java ? i.e to log all the error messages that are present during processing at one time.

as Per my understanding in java if there results an abnormality during the execution then it terminates the further execution and it throws the exception (exception for the first XML node) it does not append the other two error messages in my case for last name and salery.
 
Abhay Agarwal
Ranch Hand
Posts: 1375
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, it is achievable in java (the error messages that are present during processing at one time).

Please post your XML and XML validation code related to it. Then i can try to give you hints about how to achieve it

~ abhay
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use JAXB to convert xml to java object(unmarshalling) and then validate the attribute. do you want to show the group of error message? then if one validation fails dont throw a particular error. instead validate all the fields and put the error messages in a container like ArrayList, then show those message to user!
 
Abhay Agarwal
Ranch Hand
Posts: 1375
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
catch exception that is occuring when validation fails. Store your error message in String/Array/ArrayList and then finally display it to user.


NameValidationFailException, SalaryValidationFailException, LastNameValidationFailException are custom exceptions
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic