• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Site-wide Error Handler -CF Admin cannot insert error.cfm

Participant ,
Aug 03, 2009 Aug 03, 2009

Copy link to clipboard

Copied

Hi all, even though my cferror.cfm file location is recognized by cf admin. The cf admin is not able to call the error file when there is an error... I am using MX 7.2... Any help appreciated...

TOPICS
Advanced techniques

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 03, 2009 Aug 03, 2009

Copy link to clipboard

Copied

I do something similar, calling the site-wide error page and emailing me the error info. How are you outputting the error itself? Are you sure it exists once CF loads the site-wide error page?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 04, 2009 Aug 04, 2009

Copy link to clipboard

Copied

here is my sample cferror...CF admin says "backgroundcolor" is undefined...

<cftry>
<cfcatch type="any">
<cfswitch expression="#cfcatch.type#">
<cfcase value="template"><cfset backgroundcolor = "lightsteelblue"></cfcase>
<cfcase value="expression"><cfset backgroundcolor = "blanchedalmond"></cfcase>
<cfcase value="database"><cfset backgroundcolor = "linen"></cfcase>
<cfdefaultcase><cfset backgroundcolor = "darkkhaki"></cfdefaultcase>
</cfswitch>
</cfcatch>
</cftry>
<cfset chop = len(GetBaseTemplatePath()) - 9>

<cfoutput>
<div style="border:solid 1px green; background : #backgroundcolor#;">
<h2>THE REQUESTED PAGE IS TEMPORARILY UNAVAILABLE... PLEASE RE-VISIT IN APPROXIMATELY 30 MINS. </h2>
</div>
</cfoutput>


<cfinclude template="footer.cfm">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 04, 2009 Aug 04, 2009

Copy link to clipboard

Copied

I'd guess the cfcatch isn't actually being called? In your cfcatch type="any" block put in some text like "I failed!" instead of setting any variables, see if it gets displayed when an error happens. I usually check for the existence of cferror because calling any values inside of it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 04, 2009 Aug 04, 2009

Copy link to clipboard

Copied

How does backgroundcolor get set if there is not an error?

You are setting a variable inside the catch block of a try-catch exception handerler then trying to use that variable later, after the catch block.  Thus if no error orrcurs in the <try> block, which has no code in your example so no error can occur, no variable is getting set.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 04, 2009 Aug 04, 2009

Copy link to clipboard

Copied

I am little lost... can you guys be more specific? How to resolve the issue?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 04, 2009 Aug 04, 2009

Copy link to clipboard

Copied

Move the code where you display an error message inside your cfcatch block.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 04, 2009 Aug 04, 2009

Copy link to clipboard

Copied

<cftry>

Any code here will be watched for exceptions, but there is nothing here, so there is really nothing that can ever throw an exception.

<cfcatch type="any">

Code here will be run ONLY if there is an exception thrown in the above section.

<cfswitch expression="#cfcatch.type#">
<cfcase value="template"><cfset backgroundcolor = "lightsteelblue"></cfcase>
<cfcase value="expression"><cfset backgroundcolor = "blanchedalmond"></cfcase>
<cfcase value="database"><cfset backgroundcolor = "linen"></cfcase>
<cfdefaultcase><cfset backgroundcolor = "darkkhaki"></cfdefaultcase>
</cfswitch>
</cfcatch>
This code will set a variable named 'backgroundcolor' if it is run which will only happen if there is an exception in the watched code at the beginning of the try block.
</cftry>
This is the end of the try block.
<cfset chop = len(GetBaseTemplatePath()) - 9>

<cfoutput>
<div style="border:solid 1px green; background : #backgroundcolor#;">
<h2>THE REQUESTED PAGE IS TEMPORARILY UNAVAILABLE... PLEASE RE-VISIT IN APPROXIMATELY 30 MINS. </h2>
</div>
</cfoutput>

This code will be run wheter there is an excpetion or not.  But it is relying on a variable that is only set if there is an exception, and there is no code in inside the <cftry>...</cftry> block so there is pretty much NO chance of anything ever throwing an exception.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 06, 2009 Aug 06, 2009

Copy link to clipboard

Copied

LATEST

Thank you all.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation