I’m searching for a solution to catch errors based on the current directory. I would like to display an error message depending on the current directory which get an error.
The Application.cfc script works fine, could you support me or telling me what would be the best solution to add this information? Thank you for your support and time.
Adding soemthing like that, but not sure if Application.cfc recognized the path which got the error #GetFileFromPath("#GetCurrentTemplatePath()#")#
<cfif CGI.SCRIPT_NAME CONTAINS "home.cfm">
<cfargument name="Exception" type="any" required="true" />
<cfargument name="EventName" type="string" required="false" default="" />
<cfset infoStruct.CGI = CGI>
<cfoutput><h1>Something went wrong. Please open a ticket</h1></cfoutput>
<cfset infoStruct = StructNew()>
<cfdump var="#Exception#">
<cfdump var="#infoStruct#">
<cfelseif CGI.SCRIPT_NAME CONTAINS "support.cfm">
<cfargument name="Exception" type="any" required="true" />
<cfargument name="EventName" type="string" required="false" default="" />
<cfset infoStruct.CGI = CGI>
<cfoutput><h1>Something went wrong. Please use the following url: www.xxxxxxxx.com</h1></cfoutput>
<cfset infoStruct = StructNew()>
<cfdump var="#Exception#">
<cfdump var="#infoStruct#">
<cfelse>
other errors
</cfif>
The Application.cfc:
<cfcomponent displayname="Application" output="true" hint="Application cfc">
<cffunction name="Application_End">
<cfargument name="ApplicationScope" required=true/>
<cflog file="#This.Name#" type="Information"
text="Application #Arguments.ApplicationScope.applicationname# Ended" >
</cffunction>
<cffunction name="OnErrors" access="public" returntype="void" output="true" hint="Fires when an exception occures that is not caught by a try/catch.">
<!--- Catch errors arguments--->
<cfargument name="Exception" type="any" required="true" />
<cfargument name="EventName" type="string" required="false" default="" />
<cfset infoStruct.CGI = CGI>
<cfoutput>
<h1>Something went wrong</h1>
<h4>furhter text depending on the page name</h4>
</cfoutput>
<cfset infoStruct = StructNew()>
<cfdump var="#Exception#">
<cfdump var="#infoStruct#">
<!--- E-Mail notification--->
<cftry>
<cfset infoStruct.CGI = CGI>
<cfmail to="xxxxxx@xxxxxx.com" from="xxxxxx@xxxxxx.com" subject="error.cfm" type="html">
<cfdump var="#Exception#">
<cfdump var="#infoStruct#">
</cfmail>
</cftry>
<cfreturn />
</cffunction>