You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/06/17 17:08:41 UTC

DO NOT REPLY [Bug 29642] New: - Error in catching exception and checking instanceof

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=29642>.
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=29642

Error in catching exception and checking instanceof 

           Summary: Error in catching exception and checking instanceof
           Product: Commons
           Version: unspecified
          Platform: PC
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Validator
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: michel.cousineau@loto-quebec.com
                CC: michel.cousineau@loto-quebec.com


In class Validator method validateFieldForRule you use reflection whitch throw 
InvocationtargetException and you catch all Exception and check if its instance 
of ValidatorException since you will get a InvocationTargetException which has 
the real exception the if is useless. 

  private boolean validateFieldForRule(

 } catch (Exception e) {
            log.error("reflection: " + e.getMessage(), e);

            results.add(field, va.getName(), false);

-------->>  if (e instanceof ValidatorException) {
                throw ((ValidatorException) e);
            }
            return false;
        }
        return true;

va.lang.reflect.InvocationTargetException: 
org.apache.commons.validator.ValidatorException: Erreur lors du transport 
Exception :Can't connect to the Entitlements Server.
	at com.lq.clubvip.web.validations.Validation.validerCodeUsagerInutilise
(Validation.java:1469)

} catch (Exception e) {
            log.error("reflection: " + e.getMessage(), e);

            results.add(field, va.getName(), false);

-------->>  if (((java.lang.reflect.InvocationTargetException)
e).getTargetException() instanceof ValidatorException) {
                throw ((ValidatorException) e);
            }
            return false;
        }
        return true;

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