Copy link to clipboard
Copied
I'm using application.cfc's onError method to email me any CF exceptions that occur. Using the exception struct provided I'm able to create a somewhat detailed email message, but seems I don't have access to the same info that would normally be displayed in a CF error template, for example I want to see the lines of code that errored, to get that I would need to do a fileread on the template which seems hack-ish. Any better way to get something more like the default error handler?
Copy link to clipboard
Copied
Have you dumped the error scope, or whatever scope you're referring to in the method for individual things? It should have what you need, as keys within that strict. I'm writing from a phone so can't readily test this to know.
Copy link to clipboard
Copied
Yes the struct CF provides is very detailed, I can rebuild most information traversing it. The paths depend and change based on the type of exception. However it doesn't look like I can get the lines of code for context without reading that myself from the template. I was more just wondering if someone already did this, seems like email alerts would be a common need, but maybe that's just me, I live off of email.
Copy link to clipboard
Copied
Sure. Most folks who have error handling still send emails. Some use dbs, some more sophisticated processing.
As for for seeing the code context, it may be that you need "robust exception handling" enabled in the cf admin (debugging page). I don't recall how that affects that specific aspect of the error scope details, if at all. Worth a check. Again, am not at computer.
Copy link to clipboard
Copied
...seems I don't have access to the same info that would normally be displayed in a CF error template, for example I want to see the lines of code that errored
By @snowfields
As far as I know, none of ColdFusion's error-handling methods will show you the actual code that errored. Neither cferror, nor onError, nor try-catch.
Instead, each error struct - respectively, cferror, arguments.exception, cfcatch - shows you the file-path and line number of the code that errored. It is then up to you to use that information to locate the vexing code.