On 14 April 2011 01:10, Justin Randall <ran...@hotmail.com> wrote:
>
> Hi Chris,
>
>> Of course. I was wondering about other exceptions or errors that maybe I
>> cannot control from that code.
>
> Are you referring to internal exceptions within Tomcat's own code or simply 
> unexpected exceptions within the servlet's implemented code?  If it's the 
> later you could always just wrap your code with a try block that catches 
> "Throwable" which will catch any possible exception thrown by Java and 
> properly implemented library exceptions.  Perhaps not ideal but considering 
> the available options it might not be too bad.
>
> Technically speaking, catching Throwable isn't such a bad practice for 
> end-user facing applications because you can at least redirect to a more 
> elegant "Unexpected Exception has occurred" page rather than an error page 
> showing a stack trace of a NullPointerException or some other unexpected 
> errors due to programming mistakes as an example.

Some Throwables should never be caught - or if they are, must be rethrown.
For example, ThreadDeath and VirtualMachineError.

Should be safe to catch RuntimeException (includes NPE) and Exception.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to