how do I prevent or override output within the onException event?
i basically am trying to detect if a user is requesting a .json or .xml and output the appropriate format error message to the request.
currently, when the error happens, my logging kicks in, I have event.renderData(…) setup but it never outputs the renderData. It always outputs the default error page or error template.
Is my best bet to handle it in the error template? Thats how I am handling it now but I think there is an easier way to do it in the handler.
Jeremy R. DeYoung
I believe you have two options:
Configure a custom bugReportTemplate to output whatever you want. Warning, I don’t think it’s ran as a normal view-- it’s just cfincluded in the ExceptionService and has access to the error.
setNextEvent in your onException handler to redirect somewhere else. You can use flash RAM or queryString to persist whatever you need to correctly render the result after the jump. That might only work though if the client is willing to follow a 302 redirect. Also, make sure you don’t redirect to the same event that just errored-- hilarity might ensue, or maybe just an endless loop.