Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] ExceptionHandling

Hi!

I'm trying to handle all ServletExceptions that my Servlets throw with one aspect in a common way.

In my opinion the best way would be to use an around advice like in Listing 8.19 in the "AspectJ in Action" book:

Object around() : operations() {
  try {
    proceed();
  }
  catch ...
}

But the problem is that the methods which throw the ServletException have a different number of parameters and the types of the parameters differ, too. I can't capture all this methods with one proceed()-call, right?


Another idea ist to use this advice:

after() throwing(javax.servlet.ServletException ex) ...

But now I have the problem that the exception is already thrown and I can't catch it anymore, right?


Another problem is the common handling of the exceptions. I need the HttpServletResponse object to display the user a nice error message instead of the exception stack trace, but I have found no way to access it in the advice.

Thanks for your help in advance!

Steffen


Back to the top