tor, 16,.06.2005 kl. 09.48 +0100, skrev Daniel M Garland:
> Hi all,
> 
> I'm a beginner with the Tapestry framework, but I've read a lot of 
> tutorials and Mr. Lewis Ship's book.  One thing that I didn't 
> read/understand much about was an effective way of dealing with Tapestry 
> exceptions.
> 
> For instance I am creating a Tapestry page that creates a property from 
> a database, which is used by a number of Image components to obtain the 
> asset name. Whenever this property is inadvertently null, this would of 
> course cause a runtime exception because the Image component would not 
> know what to render.
> 
> However, in a production environment, I would never want a user to see 
> the Tapestry exception page; I would prefer the image component to do 
> nothing. Up to  now, my strategy has been to ensure that the getAsset() 
> method never returns null by wrapping it up in another method, testing 
> for nulls and then returning a default image .
> 
> I'm sure there are some best practices out there on ensuring that I can 
> prevent the exception screen reaching users in a production environment- 
> can I catch Tapestry runtime errors and have the message channeled into 
> a Insert component or even an email?
> 
> TIA
> Cheers
> Dan Garland
> 
I have made a class that rethrows exceptions on a list, so that I can
pass some exceptions on to some servlet filters.

I overrode the activateErrorPage in BaseEngine:
protected void activateExceptionPage(IRequestCycle iRequestCycle, 
        ResponseOutputStream responseOutputStream, Throwable throwable) 
        throws  ServletException {

  ExceptionRethrower exceptionRethrower = (ExceptionRethrower) 
        getBean("exceptionRethrower");
  exceptionRethrower.checkForRethrow(throwable);
  super.activateExceptionPage(iRequestCycle, responseOutputStream,
throwable);
}

In this method you could do whatever you want, but if you call the super
method, the exception page will appear.

For this to work you would have to make a subclass of BaseEngine.

What about detecting whether the asset is null, and make an empty asset.
I thik this would trigger the alt part of the Image comp.

HTH

-- 
Olve Hansen



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to