cferror template doesn't show all cf vars

I placed the following in my application.cfm file:

  <cferror type="request" template="error.cfm">

The error.cfm file contains this:

  An error has occured<br>

  <cfmail from="ArchNet@wrightengineers.com" to="admin@mysite.com" subject="ERROR" type="html">
      #error.DateTime#<br />
        #error.Template#<br />
      #error.message#<br />
  </cfmail>

This is what shows up on the page when an error occurs:

  An error has occured.
  Wed Apr 05 09:48:55 PDT 2006
  /Staff/StaffStart.cfm
  #error.message#

Huh?  Why would the first two variables display and the third one not?  And why would the cfmail be ignored?  What am I missing?
LVL 2
David WilliamsonIT DirectorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rob_lorentzCommented:
try using cfdump instead. we use this and it gives us tons of info to debug with.

<cfmail from="ArchNet@wrightengineers.com" to="admin@mysite.com" subject="ERROR" type="html">
     <cfdump var="#error#>
     <cfdump var="#cfcatch#>
     <cfdump var="#form#>
     <cfdump var="#url#>
     <cfdump var="#http#>
</cfmail>
0
rob_lorentzCommented:
ooops, sloppy, sloppy, sloppy

<cfmail from="ArchNet@wrightengineers.com" to="admin@mysite.com" subject="ERROR" type="html">
     <cfdump var="#error#">
     <cfdump var="#cfcatch#">
     <cfdump var="#form#">
     <cfdump var="#url#">
     <cfdump var="#http#">
</cfmail>
0
David WilliamsonIT DirectorAuthor Commented:
what is the difference between your two posts?  I can't tell.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

rob_lorentzCommented:
the close quote on the cfdumps
0
David WilliamsonIT DirectorAuthor Commented:
I tried using dump instead, but no email was sent.  I also included the cfdump outside of the cfmail, and there was no info displayed on the page with the error.  I included #error.generatedcontent# on the page, which does display.  Why would some of these variables display and others not?
0
David WilliamsonIT DirectorAuthor Commented:
I think I may have discovered the answer here:

http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00001121.htm#1191865

Apparently, depending on the type of cferror you specify, you can only use certain things in the error.cfm file.
0
rob_lorentzCommented:
if the variable isnt defiend, cfdump shouldn't do anything. to be extra sure you can wrap the cfdumps in siDefiend

<cfif isDefined("form")><cfdump var="#form#"></cfif>
0
digicidalCommented:
Actually I think the problem is that the parser has already run on an error type of "REQUEST".  Here is from AdobeMacro docs :
REQUEST
Handles any exception that is not otherwise-handled. The request error page runs after the CFML language processor finishes. As a result, the request error page cannot include CFML tags, but can display error page variables. A request error page is useful as a backup if errors occur in other error handlers.

Try your cferror with a type of "Exception" rather than "Request".
0
digicidalCommented:
Note the example here:
http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00001121.htm#1191865

You can specify the mailTo in the <cferror> tag itself with a type="request" however you would NOT be able to have the error page use the <cfmail> tag because no CFML will be parsed on that page.  So what you would want to do is this:
In Application.cfm:
<cferror type="request" template="error.cfm" mailTo="admin@mysite.com">

And in error.cfm:

<B>An Error occurred which critically foobared my application.</B>
------------------ General Info ------------------- <BR><BR>
WHEN: #error.dateTime#<BR>
DETAILS: #error.diagnostics#<BR>
BROWSER: #error.browser#<BR>
TEMPLATE: #error.template#<BR>
URL QRYSTR: #error.queryString#<BR>
WHO DID IT: #error.remoteAddress#<BR>
WHERE THEY CAME FROM: #error.HTTPReferer#<BR><BR>
----------------- Page Output ------------------- <BR><BR>
#error.generatedContent#
0
digicidalCommented:
Note that you can make it 'pretty' or format differently, because the output (and email) will be HTML... just not CFML.  So you could still use CSS or format a table for the different sections, etc... you just can't use any <CF...> tags of any kind within the type="Request" template page.  This is not the case with type="Exception" which will allow you to use and will parse CFML included in the template.  Optimally you should use both in error handling, using Exception for everything you would normally encounter (this is what you can CFTHROW stuff at for custom errors) and if something actually causes *Everything* to break on you to the point that even the Exception error template can't be processed, you would still be notified because that would cause the Request error template to be triggered.
0
David WilliamsonIT DirectorAuthor Commented:
I wonder if i could put two cferror tags in application.cfm?  One with type=exception and one with type=request?
0
David WilliamsonIT DirectorAuthor Commented:
I switched the cferror tag:

<cferror type="exception" template="#rp#/error.cfm">

Now my message comes up, but it still shows the big, user-unfriendly message after that.  And the email doesn't get sent, whereas it was working just a short while ago.  Shouldn't the cferror tag prevent the full error dump from appearing on the page?
0
digicidalCommented:
Well, yes and no.  Depending on how you format your page you can see much or very little.  However, in order to not see the default ColdFusion error page you need to change it in the administrator console.  Go into settings (Server Settings>Settings) and specify a template in the field labled "Site-wide Error Handler", note that you can also provide a custom page for a missing template in the field above it.  This can be your pretty and user-friendly page to display to your users.  The only problem comes from running more than one site off the same server (multi-homed servers, using HTTP headers to redirect through IIS).  They will both get this same page so that can cause problems if you have two site with dramatically different looks.

This will cover how to set up your <cferror> sections in your Application.cfm or in OnError() in Application.cfc
http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00001138.htm

In the ColdFusion MX Developer's Guide you can read more on the custom page information. Try here:
http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00001138.htm
(Essentially this expands on the info in the first link).

And still more from MX 6 here (which still applies in CF7):
http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Errors5.htm

Elsewhere you can read more on error handling and custom templates here:
http://www.houseoffusion.com/error.ppt (PowerPoint Presentation)
and an oldie but a goodie:
http://coldfusion.sys-con.com/read/41844.htm?CFID=328293&CFTOKEN=1487E0F7-1519-E0C1-7FD9DDD2F6679012

Also you should not (if this is a production site) leave the 'Enable Robust Exception Information' box checked on the Debugging page.  Since this information can be used to exploit your site, etc... In addition if you are using 5-6.1 you should read this:
http://www.macromedia.com/devnet/security/security_zone/mpsb03-06.html

Hope that helps!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David WilliamsonIT DirectorAuthor Commented:
That is very helpful, thank you for taking the time to write it all down.

So, a brief clarification, if I may, on a couple of points:

1.  Using cferror in my application.cfm will not prevent the standard user-unfriendly message from being displayed?
2.  Once I changed my cferror to an exception type, my cfmail block was working.  I was getting emails.  Suddenly I am not any more.  Can you think of any reason for this?
0
David WilliamsonIT DirectorAuthor Commented:
Alright, after fiddling around for a while, I finally figured out what was going on!  Inside the cfmail tag, one of my items was the following:

<cfif isdefined("error.tagcontext")>#error.tagcontext#</cfif>

That is what was displaying the standard error message on the screen, and at the same time it was breaking the cfmail tag, causing mail not to be sent.  As soon as I removed that part, things started behaving normally again.  Instead of the above code, I used:

<cfif isdefined("error.tagcontext")><cfdump var="#error.tagcontext#"></cfif>

Which works just fine.

 Whew!  I thought I was going mad for a while there...
0
digicidalCommented:
LOL! That's all part of exploring/discovering a 'new' area in CF!  (Of course the features have been around for awhile, but isn't it funny how error-handling is usually the LAST thing we get around to working with rather than the FIRST)  At least it always seems to be with me. :D Cheers!
0
David WilliamsonIT DirectorAuthor Commented:
Awesome.  Now I gotta figure out how to assign all these points...
0
digicidalCommented:
lol, I thought theamzngq closed this one already.  As far as I know everything is resolved as far as this is concerned.
0
David WilliamsonIT DirectorAuthor Commented:
sorry!  This one must have slipped through the cracks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.