You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2004/06/22 15:40:12 UTC

DO NOT REPLY [Bug 29736] New: - ValidatorForm.validate should be able to throw ValidatorException

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=29736>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=29736

ValidatorForm.validate should be able to throw ValidatorException  

           Summary: ValidatorForm.validate should be able to throw
                    ValidatorException
           Product: Struts
           Version: Nightly Build
          Platform: PC
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Validator Framework
        AssignedTo: dev@struts.apache.org
        ReportedBy: michel.cousineau@loto-quebec.com


The validate of the ValidatorForm should be able to throw a ValidatorException  
so that it can be trapped by an Exception Handler. 

The situation is this I've created a validator class that is called by the 
Struts validator plug-in. In my validation I've called a service that check on 
a 3rd parties software that can throw exception if I've got this exception the 
only thing that the validator let pass is a ValidatorException to I'm throwing 
one the catch is that in the ValidatorForm.validate you catch that exception 
and you are logging it !!!. 

So I cannot redirect with the ExceptionHandler the exception and redirect the 
user correctly.


   public ActionErrors validate(ActionMapping mapping,
                                 HttpServletRequest request) {

        ServletContext application = getServlet().getServletContext();
        ActionErrors errors = new ActionErrors();

        String validationKey = getValidationKey(mapping, request);

        Validator validator = Resources.initValidator(validationKey,
                             this,
                             application, request,
                             errors, page);

        try {
            validatorResults = validator.validate();
        } catch (ValidatorException e) {
------->   log.error(e.getMessage(), e);
           //Should Throw
           throw e;
        }

        return errors;

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org