velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: Velocity and wrong file name
Date Tue, 20 Feb 2001 17:50:39 GMT
Hervé Guidetti wrote:
> 
> > I checked in a tiny fix - just threw an exception in Template.merge()
> > when we didn't have an AST.   It's the same message as what is logged.
> >
> > We might want to split this into two kinds of exceptions, one for
> > 'ResourceNotFound' and the other for 'ParseError', but it may really not
> > add much value...
> >
> 
> Not sure...
> I have a multilanguage system. If a file doesn't exist, i use another file
> (default language).
> So it is important if the file exist and has error or if the file doesn't
> exist.

First,  you can tell from the velocity log what happened - if it's an
existance or parse problem.  Not sure what you would do in the
application anyway - if the file didn't exist, you would try the default
language file.  If the file had a syntax error in VTL, there is nothing
you could do at runtime anyway.  I guess you could log into the turbine
log that you have a parse error.

The fix may be a little bigger than us doing something for you in
velocity.

For example in TurbineVelocityService.java, if an exception is thrown by
merge(), it is caught, run through renderingError(), and then a Turbine
exception is thrown.

I assume you can find the class of the exception that is wrapped in
TurbineException.

The issues I see :

1) If we through something like a org.apache.velocity.XXX.ParseException
to indicate a parser exception, would this muddle up anything in Turbine
as you now have to import velocity specific things into 'upper' layers
of your code?  I really don't like this.

2) Would it be enough to distinquish between an IOException and an
Exception?  Since the two problems that can happen, at the largest
length scale are 'some issue about the file' and 'some issue within the
file', you would be able to distinguish between the two.

3) A conceptual issue is that at merge() time, you don't actually go
find the file.  That would have happened before you get to call
merge().  We can throw an IOException to indicate that we don't have a
valid parsed template because of file reasons, which may be a little
more honest that a FileNotFoundException, because we can't currently
tell if it's an actual FileNotFoundException, or other things (like if
the FileResourceLoader is enforcing security and rejects a filename
because it has a '..' in the path...).

I will start working down #2/#3 and if no one has any better
suggestions... :)

geir

-- 
Geir Magnusson Jr.                               geirm@optonline.com

Developing for the web?  See http://jakarta.apache.org/velocity

Mime
View raw message