Will asks:
If a ColdFusion hosting service has the "robust error reporting" turned off, is there a way around it? Without a massive try/catch setup, that is. Any "cfsetting" or anything?It's tough to debug this message: Cannot convert "" to a number. .... when you have NO idea which of 50 function calls it could be!
Absolutely. The "Enable Robust Exception Information" setting applies to the error you see on the web page itself. This setting should always be turned off on a production server. However, you can still get detailed error information. Simply use the cferror tag in your Application.cfc/cfc file. You can point to a template that simply does: <cfdump var="#error#">. While it isn't as pretty as the normal exception handler, it does give you all the information you need.
Archived Comments
Yep, this is what I do. I use the "error" collection to build a formatted mail message which is automatically sent to the site administrator in the event of exceptions. Works perfectly.
As you point out, you can also use it to populate a site-wide error template for display. I check the "cgi.server_name" parameter and if the app is on a development box I allow the template to dump all the contents of the error struct, if it's on a production server, then I output only very basic details. Again, it works well and is straightforward to implement.
error.stacktrace is my favourite. Very useful info that does not get into the error logs.
DK
Hey Doug,
Can you elaborate on that error.stacktrace bit? Is that a java object call or something? I'm pretty much a base cold fusion tags/functions user, not very familiar with most of the lower level stuff.
Guys,
I am using cferror tag to point to a template which contains user friendly error message and internally i want to send a mail to myself for debugging it. I read in the help files that the template to which we point in cferror should a html page and we cannot use cftags in that. Then how youll manage to put cfmail tag in that template??? Can anybody please explain me
Jay, that depends on the TYPE of error. You see, you can have more than one cferror tag. If the type is request then you cannot use CFML. See the docs for more info. In the past what I've done is had a type=exception for my 'real' error handling, and then type='request' for my 'oh crap nothing is working' type error. It's fine to have them both.