Hi gang,

This is the first time I’ve customized the Main.onException method and I’m having some issues working with it. Here is what I have:

var rc = event.getCollection(); var prc = event.getCollection(private=true); var exceptionBean = event.getValue("ExceptionBean"); //log to logbox if( log.canError() ){ log.error('Error',exceptionBean); } event.renderData(data='Some JSON data would go here', type="json", statusCode="500", statusText="Sorry an Error has occurred", jsonAsText="true");

The first issue i’m having is the logging is taking place however var exceptionBean does not contain anything. Secondly, instead of I’d like to return a nice JSON error message but the default exception page is being returned. How can I accomplish sending back JSON from this method. Does this require modifying the customErrorTemplate setting in the CB config file?



Hi Nolan,

once an exception is detected and the onException handler is called it is called from the exception service. Once the execution is finalized, the service tries to render the bug report template (custom or not). As the request is no longer qualified as an exception has been thrown.

From the bug report template you can decide what to render back.

Luis F. Majano
Ortus Solutions, Corp

ColdBox Platform:
Linked In:
IECFUG Manager: