[
http://issues.apache.org/jira/browse/VELOCITY-436?page=comments#action_12402336
]
Brian Ewins commented on VELOCITY-436:
--------------------------------------
I was just passing through wondering if this very issue had been discussed -
since you ask, pretty much every method of VelocityEngine 'throws Exception',
its 'orrible. Specific examples would be eg
public void init() throws java.lang.Exception
or
public Template getTemplate(java.lang.String name)
throws ResourceNotFoundException, ParseErrorException,
java.lang.Exception
In this case (but not every case) the java.lang.Exception is actually
documented as having a specific reason. Examples of this are everywhere though,
its not just VelocityEngine; Velocity and VelocityEngine are just passing
through any Exception thrown in RuntimeInstance, including ones created like
this:
throw new Exception(err);
(in RuntimeInstance.initializeIntrospection(), and throughout that class). If
those were changed to throw new VelocityException(err) it seems the 'throws
Exception' wouldn't be necessary in any of these classes.
A related issue with these particular exceptions is that they are being logged
when they are thrown. This will inevitably lead to double-logging of errors;
since not every error can be logged at the point it is thrown (eg an NPE) its
more common to throw the exception and assume the user will log it when the
exception is consumed. Its especially true right now, since its impossible to
distinguish exceptions thrown by Velocity (which are already logged) from
exceptions thrown by Velocity for other reasons (which are not logged) or
java.lang.Exceptions from anywhere else (which are also not logged)
> Remove "Exception" type throwing.
> ---------------------------------
>
> Key: VELOCITY-436
> URL: http://issues.apache.org/jira/browse/VELOCITY-436
> Project: Velocity
> Type: Improvement
> Components: Source
> Environment: NA
> Reporter: Waldemar Baraldi
> Priority: Trivial
>
> I have to use Checkstyle coding standards at my job. Some methos of Velocity
> throw exceptions using the raw "Exception" type. So Checkstyle points an
> error everywhere I use Velocity and, unfortunately, that's a fact I cannot
> override in my source code. So it would be nice if those "throws Exception"
> are replaced by some Velocity proper exception.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]