[coldbox-4]: Got redirect loop on Interceptor onException()

I was trying to implement Global onException Interceptor as described on http://wiki.coldbox.org/wiki/ExceptionHandling.cfm. When an exception happened, I got redirect loop message on my browser. Could anyone help me why I got redirect loop and how to fix it?

/config/Coldbox.cfc
I don’t have coldbox.exceptionHandler defined.

/interceptors/ExceptionHandler.cfc

component extends=“coldbox.system.Interceptor” {

function onException(event, interceptData){
var exception = arguments.interceptData.exception;

//writeDump(arguments.interceptData); // I can see the exception in interceptData.
//abort;

setNextEvent( “main.onException” );
}

}

/handlers/main.cfc
component {

function home(event, rc, prc) {
writeDump(foo);
}

function onException(event, rc, prc) {
//Grab Exception from private request collection, placed by ColdBox Exception Handling
var exception = prc.exception;
writeDump(exception);

abort;
}

}

So, when I called http://localhost/index.cfm?event=main.home, it redirected to main.onException because foo is not defined. Then, the redirect loop message showed up on the browser. I am puzzled.

You need to figure out why you’re getting thrown to the exception side of things first and foremost. Secondly why are you redirecting it back to the exception handling to run it again. I am sure this is not the way to do it, as it has been awhile.

But my guess is simple and is a gotcha if you’re not aware how this all works. If the core of your application has an issue, and you redirect back to your application it is going to throw the exception again hence the reloop.

If you don’t know how to provide or turn on logging, I suggest reading up on it and use it to log these things in areas where you need to know certain things could go wrong don’t and if they do then there is a log.

I can’t stress enough, that issues like this are commonly solved by using your own logs and looking at them.