[Coldbox 3.5.2] onError firing twice with http status code set to 500.

I’m working on a rest application and have a BaseRestHandler all my handlers inherit from. This base handler has an ‘onError’ method implemented to trap errors and return a nicely formatted JSON message letting the client know what happened. What I’m noticing after implementing some logging is that this method is firing twice when I specify the event.renderData with a statusCode argument of 500. If its 200 or not specified it only fires once. Thoughts on why its behaving like this?

`

function onError(event,rc,prc,faultAction,exception){
prc.response.success = false;

writeLog(application=true,text=“onError executed”);

event.renderData(data=prc.response, type=rc.format, statusCode=“500”);

}

`

Thanks in advance.
Brett

My Guess would be that there might be a time when prc.response.success may not exist to confirm this put a try block around the code and catch the error with an abort and dump of cfcatch will prove or eliminate this.

Andrew,

Interesting idea. I took this tact instead and just got rid of the prc.response reference all together. Same problem:

`

function onError(event,rc,prc,faultAction,exception){
writeLog(application=true,text=“onError executed”);

var response = {“test”=“test”};

event.renderData(data=response, type=“json”, statusCode=“500”);
}

`