You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Vaneet Sharma <Va...@iwg.info> on 2002/05/23 17:31:37 UTC

RE: Velocity Eror

i know about that method .. i did override it.. but when i delibrately make
error in my VM file -. for eg
  i do like this . #if 
   and i dont put end with if.. so that velocity generate error.
  but my onError method is not called .. why guysssssss
 tell me how i can show the user custimize error..
   chao

-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
Sent: 22 May 2002 17:51
To: velocity-user@jakarta.apache.org
Subject: Re: Velocity Tools Source


On 5/22/02 11:44 AM, "Vaneet Sharma" <Va...@iwg.info> wrote:

> 
> Can anyone tell me.
> how should i call  and display an customized error to user when an error
> occurs in Velocity template language.
> i did that .. for servlet. whenever any servlet gets an exception, i
called
> a method to display error on another page but
> when i delibrately make error in VM file.. blank page comes without
calling
> anything.
> I want when the error comes..  it should be redirected to my error page.
> My error page is getting hold of Servlet errors buit not Velocity error.
> 
>  i hope to get a reply


It depends on how you are using Velocity in a servlet.

If you are using the VelocityServlet, there is an error handling mechanism.
In VelocityServlet, there is 'onError()' (or something - don¹t remember)
that is called when an exception happens merging (at least).

Is that what you are looking for?

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Velocity Eror

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 5/23/02 11:31 AM, "Vaneet Sharma" <Va...@iwg.info> wrote:

> i know about that method .. i did override it.. but when i delibrately make
> error in my VM file -. for eg
> i do like this . #if
>  and i dont put end with if.. so that velocity generate error.

Right - so Velocity will throw a ParseErrorException from getTemplate().

So in handleRequest( req, resp, ctx), you can catch the ParseErrorException,
and then you can :

1) use the HttpServletRequest/Response objects to send a response back to
the user

2) return 'null' so VelocityServlet knows you answered the request (and it
won't do anything...)

geir

> but my onError method is not called .. why guysssssss
> tell me how i can show the user custimize error..
>  chao
> 
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: 22 May 2002 17:51
> To: velocity-user@jakarta.apache.org
> Subject: Re: Velocity Tools Source
> 
> 
> On 5/22/02 11:44 AM, "Vaneet Sharma" <Va...@iwg.info> wrote:
> 
>> 
>> Can anyone tell me.
>> how should i call  and display an customized error to user when an error
>> occurs in Velocity template language.
>> i did that .. for servlet. whenever any servlet gets an exception, i
> called
>> a method to display error on another page but
>> when i delibrately make error in VM file.. blank page comes without
> calling
>> anything.
>> I want when the error comes..  it should be redirected to my error page.
>> My error page is getting hold of Servlet errors buit not Velocity error.
>> 
>>  i hope to get a reply
> 
> 
> It depends on how you are using Velocity in a servlet.
> 
> If you are using the VelocityServlet, there is an error handling mechanism.
> In VelocityServlet, there is 'onError()' (or something - don¹t remember)
> that is called when an exception happens merging (at least).
> 
> Is that what you are looking for?

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>