How VRaptor3 handle Exception in Controller Methods

Hi, All

I have this situation,
in my controller layer, they may throw exceptions, and I want to handle them in one place, for example, I want to log the exception details and forward the request to a jsp page to display some info to our clients.

is there any ways to satisfy my request?

pls be kindly reply this top in English or Chinese~thanks

you can create an interceptor to handle exceptions

Hi haiker. You are using the Vraptor3 or other version?

Do you need handle exceptions to display a more friendly error page for users or only for logging?

There are a issue at github ( to create a pretty exception handler. See this page too:

So if you only need to logging the error and return to a generic page, you can use the error-page into your web.xml and create a simple interceptor to generate your log. See bellow.

public class MyLoggingInterceptor implements Interceptor {

public boolean accepts(ResourceMethod method) {
    return true; // intercept all requests

public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance)
    throws InterceptionException {
    try {, resourceInstance);
    } catch (Exception e) {
        // my log code
        // you can only print the log message or send by email, etc


Best regards

thank you all for your kindly response.

I like vraptor, it makes things easy~ :stuck_out_tongue: