This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Exception object catching multiple exceptions in one time? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Exception object catching multiple exceptions in one time? " Watch "Exception object catching multiple exceptions in one time? " New topic
Author

Exception object catching multiple exceptions in one time?

siddhu Math
Ranch Hand

Joined: Aug 10, 2006
Posts: 46
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

Joined: Feb 29, 2008
Posts: 1067
    
    1

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

Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Feb 29, 2008
Posts: 1067
    
    1

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
 
 
subject: Exception object catching multiple exceptions in one time?
 
Similar Threads
my Tree node labels are not displayed entirely.
appfuse validation problem
Regular Expression or else?
Validate xml against schema
Still struggling to get started with JSF.