Following on from this question jQuery Ajax error handling, show custom exception messages I am trying to display to my users a custom error message from ColdFusion (via AJAX) when a form is submitted but an error has occured.
I have tried to do this using a standard <cfthrow errorcode="500" message="You did something wrong"/>
which would return back to jQuery an response status code that is not 200 hence its easy to show the error like such:
...
error: function (xhr, textStatus, thrownError) {
$('p').text(thrownError);
}
However, in ColdFusion production servers it is recommended to turn off error reporting in the debug settings. So now all my user sees is "Internal server error"
instead of the custom message.
My temporary solution now is to just do a <cfreturn "Error: You did something wrong"/> <cfabort>
and then make jQuery look for any returned result from the server where the text starts with "Error:".
I would much rather use proper exception handling with <cfthrow>
. How can this be achieved given the recommendation to turn debugging off?