exception handler class

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

exception handler class

Chris Cheshire
I'm a little confused at the unhandled exception handling mechanism.

The documentation gives an example on how to get implement a handler for it (http://www.stripesframework.org/display/stripes/Exception+Handling) and I am looking at the bottom example which gives access to the action bean that triggered the exception.

However, not only does the handle() method in the interface throw exceptions (Servlet, IO), but the execute method on an ActionBean throws an Exception as well. So what happens when the handler for otherwise unhandled exceptions throws an unhandled exception?

At this point are we back to the default tomcat stack trace page?


------------------------------------------------------------------------------
Own the Future-Intel® Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game
on Steam. $5K grand prize plus 10 genre and skill prizes.
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: exception handler class

VANKEISBELCK Remi
Hi Chris,

It only declares IOException and ServletException because the handler itself may fail (e.g. call to request.getDispatcher()), or so that, in case you want to, you can re-throw an exception that matches the servlet spec, and then let the container handle it.

HTH

Remi


Le 2 avr. 2013 à 01:20, Chris Cheshire a écrit :

I'm a little confused at the unhandled exception handling mechanism.

The documentation gives an example on how to get implement a handler for it (http://www.stripesframework.org/display/stripes/Exception+Handling) and I am looking at the bottom example which gives access to the action bean that triggered the exception.

However, not only does the handle() method in the interface throw exceptions (Servlet, IO), but the execute method on an ActionBean throws an Exception as well. So what happens when the handler for otherwise unhandled exceptions throws an unhandled exception?

At this point are we back to the default tomcat stack trace page?

------------------------------------------------------------------------------
Own the Future-Intel® Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game
on Steam. $5K grand prize plus 10 genre and skill prizes.
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete
for recognition, cash, and the chance to get your game on Steam.
$5K grand prize plus 10 genre and skill prizes. Submit your demo
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: exception handler class

Chris Cheshire
So if I want to hide the stack trace output entirely, I still need a handler defined by <error-page><exception-type> ... in web.xml just in case the Stripes exception handling mechanism craps out then?


On Tue, Apr 2, 2013 at 4:24 AM, Remi VANKEISBELCK <[hidden email]> wrote:
Hi Chris,

It only declares IOException and ServletException because the handler itself may fail (e.g. call to request.getDispatcher()), or so that, in case you want to, you can re-throw an exception that matches the servlet spec, and then let the container handle it.

HTH

Remi


Le 2 avr. 2013 à 01:20, Chris Cheshire a écrit :

I'm a little confused at the unhandled exception handling mechanism.

The documentation gives an example on how to get implement a handler for it (http://www.stripesframework.org/display/stripes/Exception+Handling) and I am looking at the bottom example which gives access to the action bean that triggered the exception.

However, not only does the handle() method in the interface throw exceptions (Servlet, IO), but the execute method on an ActionBean throws an Exception as well. So what happens when the handler for otherwise unhandled exceptions throws an unhandled exception?

At this point are we back to the default tomcat stack trace page?

------------------------------------------------------------------------------
Own the Future-Intel&reg; Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game
on Steam. $5K grand prize plus 10 genre and skill prizes.
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete
for recognition, cash, and the chance to get your game on Steam.
$5K grand prize plus 10 genre and skill prizes. Submit your demo
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete
for recognition, cash, and the chance to get your game on Steam.
$5K grand prize plus 10 genre and skill prizes. Submit your demo
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: exception handler class

VANKEISBELCK Remi
Note that when using request.getDispatcher() it's boiling down to the container "crapping out" :P
Could happen e.g. if you try to dispatch to a non existing resource or stuff like that.

If you wanna avoid this entirely then wrap everything in a try/catch in your Stripes exception handler. Then you can log the error in the "catch" statement and build the response you want, but as you'll call servlet API that throws ServletException and IOException you'll have to deal with it yourself anyways, and probably end up delegating to the container...

I've had a look and if you use AutoExceptionHandler you don't even have to declare those exceptions... They will be automatically handled by the container. I'm using this myself and never has this problem : Stripes never failed to execute the resolutions returned from my exception handlers. Otoh, it definitely can happen even without any biz logic in your handler (e.g. network failure, OOM, etc.).

So I guess that the error JSP page in web.xml is the only way to really ensure that no stack trace is ever shown.

Cheers

Remi 

Le 2 avr. 2013 à 17:05, Chris Cheshire a écrit :

So if I want to hide the stack trace output entirely, I still need a handler defined by <error-page><exception-type> ... in web.xml just in case the Stripes exception handling mechanism craps out then?


On Tue, Apr 2, 2013 at 4:24 AM, Remi VANKEISBELCK <[hidden email]> wrote:
Hi Chris,

It only declares IOException and ServletException because the handler itself may fail (e.g. call to request.getDispatcher()), or so that, in case you want to, you can re-throw an exception that matches the servlet spec, and then let the container handle it.

HTH

Remi


Le 2 avr. 2013 à 01:20, Chris Cheshire a écrit :

I'm a little confused at the unhandled exception handling mechanism.

The documentation gives an example on how to get implement a handler for it (http://www.stripesframework.org/display/stripes/Exception+Handling) and I am looking at the bottom example which gives access to the action bean that triggered the exception.

However, not only does the handle() method in the interface throw exceptions (Servlet, IO), but the execute method on an ActionBean throws an Exception as well. So what happens when the handler for otherwise unhandled exceptions throws an unhandled exception?

At this point are we back to the default tomcat stack trace page?

------------------------------------------------------------------------------
Own the Future-Intel&reg; Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game
on Steam. $5K grand prize plus 10 genre and skill prizes.
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete
for recognition, cash, and the chance to get your game on Steam.
$5K grand prize plus 10 genre and skill prizes. Submit your demo
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete
for recognition, cash, and the chance to get your game on Steam.
$5K grand prize plus 10 genre and skill prizes. Submit your demo
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: exception handler class

Chris Cheshire
Thanks Remi, I'll combine them both then. At least with the Stripes exception handling I get to fire off internal emails about the issue.


On Tue, Apr 2, 2013 at 11:43 AM, Remi VANKEISBELCK <[hidden email]> wrote:
Note that when using request.getDispatcher() it's boiling down to the container "crapping out" :P
Could happen e.g. if you try to dispatch to a non existing resource or stuff like that.

If you wanna avoid this entirely then wrap everything in a try/catch in your Stripes exception handler. Then you can log the error in the "catch" statement and build the response you want, but as you'll call servlet API that throws ServletException and IOException you'll have to deal with it yourself anyways, and probably end up delegating to the container...

I've had a look and if you use AutoExceptionHandler you don't even have to declare those exceptions... They will be automatically handled by the container. I'm using this myself and never has this problem : Stripes never failed to execute the resolutions returned from my exception handlers. Otoh, it definitely can happen even without any biz logic in your handler (e.g. network failure, OOM, etc.).

So I guess that the error JSP page in web.xml is the only way to really ensure that no stack trace is ever shown.

Cheers

Remi 

Le 2 avr. 2013 à 17:05, Chris Cheshire a écrit :

So if I want to hide the stack trace output entirely, I still need a handler defined by <error-page><exception-type> ... in web.xml just in case the Stripes exception handling mechanism craps out then?


On Tue, Apr 2, 2013 at 4:24 AM, Remi VANKEISBELCK <[hidden email]> wrote:
Hi Chris,

It only declares IOException and ServletException because the handler itself may fail (e.g. call to request.getDispatcher()), or so that, in case you want to, you can re-throw an exception that matches the servlet spec, and then let the container handle it.

HTH

Remi


Le 2 avr. 2013 à 01:20, Chris Cheshire a écrit :

I'm a little confused at the unhandled exception handling mechanism.

The documentation gives an example on how to get implement a handler for it (http://www.stripesframework.org/display/stripes/Exception+Handling) and I am looking at the bottom example which gives access to the action bean that triggered the exception.

However, not only does the handle() method in the interface throw exceptions (Servlet, IO), but the execute method on an ActionBean throws an Exception as well. So what happens when the handler for otherwise unhandled exceptions throws an unhandled exception?

At this point are we back to the default tomcat stack trace page?

------------------------------------------------------------------------------
Own the Future-Intel&reg; Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game
on Steam. $5K grand prize plus 10 genre and skill prizes.
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete
for recognition, cash, and the chance to get your game on Steam.
$5K grand prize plus 10 genre and skill prizes. Submit your demo
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete
for recognition, cash, and the chance to get your game on Steam.
$5K grand prize plus 10 genre and skill prizes. Submit your demo
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users