velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ford, Peter" <Peter.F...@travelocity.com>
Subject Exception in nested #parse() not getting reported
Date Fri, 16 Jul 2004 14:42:27 GMT

I have a purpose-built resource loader that works something like the FileResourceLoader. The
difference is that it can take a "brand" qualifier like this:

#parse( "template%brand" )

The loader splits on the % and uses the "brand" part to locate a directory. The "template"
part then identifies a file within that directory. The loader has to do a trivial bit of string
manipulation with the directory and template names on the way. The template name is usually
fixed in my text and the "brand" part is passed in as a context value so I usually have something
like this:

#parse( "template%${brand}" )

This has been working fine so far.

Now here's the actual problem I've been seeing. Let's say I call this with a "brand" value
that the resource loader doesn't know. If I call up the template containing that construct
directly then I get an error as expected - the resource loader throws a ResourceNotFoundException,
Velocity catches it and aborts the processing with an Exception to the calling code. That's
fine.

Now if I call up that template inside a #parse call from another template, it doesn't behave
the way I expected. The loader is still throwing the Exception and it shows in the velocity.log,
and it seems to abort the processing of the template at that point, but the Exception doesn't
make it all the way up to the calling code. As a result the caller assumes the template processed
out ok when in fact it didn't.

One thing that may be a clue is that the error message in the log is different. If I call
the failing template directly I get:

[error] #parse(): cannot find template 'template%brand', called from template basic.txt at
(7, 1)

But if it's nested I see this instead:

[error] Exception rendering #parse( basic.txt )  : org.apache.velocity.exception.ResourceNotFoundException:
Unable to find resource 'template%brand'

I don't think this is a problem in my resource loader because it is throwing the correct exceptions
when it should, but I mention it in case it may have a bearing; it should be possible to reproduce
this problem using the FileResourceLoader.

I'm not sure if this is a bug or something wrong in a configuration setting, or maybe a bad
assumption on my part about how this is supposed to work.

--Pete

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


Mime
View raw message