You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Geir Magnusson Jr." <ge...@optonline.net> on 2001/11/28 19:08:07 UTC
Re: ReferenceException
On 11/28/01 12:46 PM, "Lukas Zimmermann" <lu...@liebhart.com>
wrote:
> Hi all
>
> I'm developing an application framework for data mapping between
> different systems. For this, data from a source system is read into
> an internal representation and then rendered into a target format
> with Velocity.
>
> Now my problem is that the application needs to get an Exception
> from Velocity when a bad reference in a template is found because
> the data mapping mustn't be done if there is a single error in
> the template or data is missing in the context.
>
> Is there a possibility that ReferenceExceptions get propagated to
> the caller of the merge method?
> (My workaround for the moment is to install my own LogSystem that
> looks at the log message whether a ReferenceException is thrown.)
>
> Thanks and regards,
> Lukas
>
Actually, yes, sort of. There is a feature called events, where you can
implement a handler. There is a handler that is invoked on every
non-escaped reference render if you have an EventCartridge in your context
(see the dev guide and the event_example in /examples).
Using this, you can see when your reference has a null value, and then do
what you want to do...
Would that help?
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: ReferenceException
Posted by Lukas Zimmermann <lu...@liebhart.com>.
"Geir Magnusson Jr." wrote:
>
> On 11/28/01 1:55 PM, "Lukas Zimmermann" <lu...@liebhart.com>
> wrote:
>
> > OK, convinced!
>
> Of what? Event handlers can't throw rightnow.... The best you can do is
> tell the app that something is wrong and not to use the resulting render...
I see...
Well that would do for now, I think.
For me the tail side of your coin would be sufficient but I agree that
head would be more flexible.
>
> > Thanks again.
> > Lukas
> >
> > "Geir Magnusson Jr." wrote:
> >>
> >> On 11/28/01 1:34 PM, "Lukas Zimmermann" <lu...@liebhart.com>
> >> wrote:
> >>
> >>> Yes, thanks a lot, this helps,
> >>> I didn't come onto this by myself, much more better than looking into
> >>> log messages ;-).
> >>>
> >>> But for my kind of application it would be more natural if a
> >>> ReferenceException would be thrown. Would you regard it as an option
> >>> to introduce a property by which this may be controlled?
> >>
> >> I am sitting here tossing a coin :)
> >>
> >> Heads : we let any event handler throw an exception - that way you can
> >> customize how this works. For example, you may want to throw an exception
> >> when only certain references 'fail', rather than all.
> >>
> >> Tails : there is a switch that has it thrown all the time.
> >>
> >> I think Heads covers Tails with added functionality...
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
>
> --
> Geir Magnusson Jr. geirm@optonline.net
> System and Software Consulting
> "He who throws mud only loses ground." - Fat Albert
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: ReferenceException
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 11/28/01 1:55 PM, "Lukas Zimmermann" <lu...@liebhart.com>
wrote:
> OK, convinced!
Of what? Event handlers can't throw rightnow.... The best you can do is
tell the app that something is wrong and not to use the resulting render...
> Thanks again.
> Lukas
>
> "Geir Magnusson Jr." wrote:
>>
>> On 11/28/01 1:34 PM, "Lukas Zimmermann" <lu...@liebhart.com>
>> wrote:
>>
>>> Yes, thanks a lot, this helps,
>>> I didn't come onto this by myself, much more better than looking into
>>> log messages ;-).
>>>
>>> But for my kind of application it would be more natural if a
>>> ReferenceException would be thrown. Would you regard it as an option
>>> to introduce a property by which this may be controlled?
>>
>> I am sitting here tossing a coin :)
>>
>> Heads : we let any event handler throw an exception - that way you can
>> customize how this works. For example, you may want to throw an exception
>> when only certain references 'fail', rather than all.
>>
>> Tails : there is a switch that has it thrown all the time.
>>
>> I think Heads covers Tails with added functionality...
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: ReferenceException
Posted by Lukas Zimmermann <lu...@liebhart.com>.
OK, convinced!
Thanks again.
Lukas
"Geir Magnusson Jr." wrote:
>
> On 11/28/01 1:34 PM, "Lukas Zimmermann" <lu...@liebhart.com>
> wrote:
>
> > Yes, thanks a lot, this helps,
> > I didn't come onto this by myself, much more better than looking into
> > log messages ;-).
> >
> > But for my kind of application it would be more natural if a
> > ReferenceException would be thrown. Would you regard it as an option
> > to introduce a property by which this may be controlled?
>
> I am sitting here tossing a coin :)
>
> Heads : we let any event handler throw an exception - that way you can
> customize how this works. For example, you may want to throw an exception
> when only certain references 'fail', rather than all.
>
> Tails : there is a switch that has it thrown all the time.
>
> I think Heads covers Tails with added functionality...
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: ReferenceException
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 11/28/01 1:34 PM, "Lukas Zimmermann" <lu...@liebhart.com>
wrote:
> Yes, thanks a lot, this helps,
> I didn't come onto this by myself, much more better than looking into
> log messages ;-).
>
> But for my kind of application it would be more natural if a
> ReferenceException would be thrown. Would you regard it as an option
> to introduce a property by which this may be controlled?
I am sitting here tossing a coin :)
Heads : we let any event handler throw an exception - that way you can
customize how this works. For example, you may want to throw an exception
when only certain references 'fail', rather than all.
Tails : there is a switch that has it thrown all the time.
I think Heads covers Tails with added functionality...
>
> "Geir Magnusson Jr." wrote:
>>
>> On 11/28/01 12:46 PM, "Lukas Zimmermann" <lu...@liebhart.com>
>> wrote:
>>
>>> Hi all
>>>
>>> I'm developing an application framework for data mapping between
>>> different systems. For this, data from a source system is read into
>>> an internal representation and then rendered into a target format
>>> with Velocity.
>>>
>>> Now my problem is that the application needs to get an Exception
>>> from Velocity when a bad reference in a template is found because
>>> the data mapping mustn't be done if there is a single error in
>>> the template or data is missing in the context.
>>>
>>> Is there a possibility that ReferenceExceptions get propagated to
>>> the caller of the merge method?
>>> (My workaround for the moment is to install my own LogSystem that
>>> looks at the log message whether a ReferenceException is thrown.)
>>>
>>> Thanks and regards,
>>> Lukas
>>>
>>
>> Actually, yes, sort of. There is a feature called events, where you can
>> implement a handler. There is a handler that is invoked on every
>> non-escaped reference render if you have an EventCartridge in your context
>> (see the dev guide and the event_example in /examples).
>>
>> Using this, you can see when your reference has a null value, and then do
>> what you want to do...
>>
>> Would that help?
>>
>> --
>> Geir Magnusson Jr. geirm@optonline.net
>> System and Software Consulting
>> "He who throws mud only loses ground." - Fat Albert
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: ReferenceException
Posted by Lukas Zimmermann <lu...@liebhart.com>.
Yes, thanks a lot, this helps,
I didn't come onto this by myself, much more better than looking into
log messages ;-).
But for my kind of application it would be more natural if a
ReferenceException would be thrown. Would you regard it as an option
to introduce a property by which this may be controlled?
"Geir Magnusson Jr." wrote:
>
> On 11/28/01 12:46 PM, "Lukas Zimmermann" <lu...@liebhart.com>
> wrote:
>
> > Hi all
> >
> > I'm developing an application framework for data mapping between
> > different systems. For this, data from a source system is read into
> > an internal representation and then rendered into a target format
> > with Velocity.
> >
> > Now my problem is that the application needs to get an Exception
> > from Velocity when a bad reference in a template is found because
> > the data mapping mustn't be done if there is a single error in
> > the template or data is missing in the context.
> >
> > Is there a possibility that ReferenceExceptions get propagated to
> > the caller of the merge method?
> > (My workaround for the moment is to install my own LogSystem that
> > looks at the log message whether a ReferenceException is thrown.)
> >
> > Thanks and regards,
> > Lukas
> >
>
> Actually, yes, sort of. There is a feature called events, where you can
> implement a handler. There is a handler that is invoked on every
> non-escaped reference render if you have an EventCartridge in your context
> (see the dev guide and the event_example in /examples).
>
> Using this, you can see when your reference has a null value, and then do
> what you want to do...
>
> Would that help?
>
> --
> Geir Magnusson Jr. geirm@optonline.net
> System and Software Consulting
> "He who throws mud only loses ground." - Fat Albert
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>