Daemonite: CFMX Global Error Handler Archive

Daemonite: CFMX Global Error Handler Archive


Friday, July 26, 2002
CFMX Global Error Handler

The global error handler in CFMX behaves quite differently to that in ColdFusion 5. The documentation surrounding the change in functionality is not the best. On top of that it looks like there are a few quirks to look out for.

Here are a list of issues with we've found with the CFMX global error handler:

  1. It is now a relative address and not an absolute address to reference the error template... this much is mentioned in a sentence beneath the field to enter the template address
    1. Relative to what? It appears that it is *only* relative to the server settings page in the CF Administrator. At least you cannot record a template location without specifying something relative to the settings template in CF Administrator. You can get around this by setting it relative to the web root of the server but what happens if your CFIDE is on a different domain to the web app?
    2. Does it have to be exposed under the webroot? I can't see anyway of nominating a global error handler that is not within the webroot. Also something that is not specifically visible to the same domain under which you are running CFIDE. On a multihomed server... you may have to set up a virtual for the errorhandler as well.
  2. It does not appear to reference the CFERROR or ERROR scopes when it fires. If I invoke the error handler by generating an error and use CFERROR to locate the error handler it works fine. The exact same code in invoking by global error handler reference breaks giving one of those annoying server 500 errors. Putting in an IsDefined("error") test works with CFERROR and fails for GLOBAL. The documentation implies that both mechanisms for error handlers (ie GLOBAL and using CFERROR) should have access to the same error (or cferror) structure. [A bug has been raised for this]
  3. The global error handler (assuming you don't actually need to reference the ERROR structure *boggle*) will run and execute CFML code. However, it includes all content generated up to the point the error occurs. I haven't got CF5 available here now to confirm this behaviour but I'm sure it use to discard everything and generate a page containing only the content on the error handler template. No doubt you could use CFCONTENT or something to dump this intial output but my point is it is very different behaviour to previous versions that at least rates a note in the documentation.

The test case is very simple:

-- file called /errortest/mypage.cfm
<!--- <cferror type="EXCEPTION" template="/errortest/errorhandler.cfm"> --->
<cfquery datasource="cfsnippets" name="q">
SELECT * FROM coursesX
</cfquery>


-- file called /errortest/errorhandler.cfm
<div style="border: 2px red dashed; padding: 20px 20px 20px 20px;">
<h2>Error Handler</h2>
<cfif IsDefined("cferror")>
<cfdump var="#cferror#">
<cfelse>
ERROR not here
</cfif>
</div>

Posted by modius at 11:23 PM | Permalink
Trackback: http://blog.daemon.com.au/cgi-bin/dmblog/mt-tb.cgi/30

Comments

The following known issue was fixed in "CFMX Updater 1":
ERROR.* variables were not available in the site-wide error handler. BUG 46761

Posted by: Geoff Bowers on November 25, 2002 04:26 PM