I have a ColdFusion template, which will be called via ajax.
The template has timeout of seconds like:
<cfsetting showdebugoutput="true" requesttimeout="2" />
But if the timeout occurs, I get no error message back. Is there a way to catch the timeout and respond properly via Ajax?
Do you get anything back? Your response should still contain the text ColdFusion produces. Have you used Chrome, or fire bug or any browser with web tools that allow you to see the response to see if you’re just getting back something you can’t use? Are you using anything with a success/fail callback function that may be suppressing the failure on the client side? If the below suggestion doesn’t help, I’d post your JS and re-tag your question.
That being said: any time you do anything after the request timeout has expired you’ll want to extend your timeout. onError and try/catch only have a few MS after the timeout to react to the error so sending messages or logging errors will also fail. If you were trying to send an email or write to a file, you’re CF error message would then say your cfmail or cffile action timed out which it did (technically) but it isn’t what caused the initial error.
You can simply reset the requestTimeout to something a little bigger if you know what the timeout is already.
Or you can add time if you don’t know the current timeout value.
You do not have to do this in a try/catch block either, you can include this in your onError event handler if you have one defined in your application.cfc.