I want to display the custom errror…I am not getting how to start the code…Or how to start writing onError method,can u help me with the flow and if possible send some sample code for hadling the custom error
Suggestion for a simple onError method:
<cffunction name=”onError”>
<cfargument name=”exception” required=true>
<cfargument name = “eventName” required=true>
<p><cfoutput>OnError – event: #arguments.eventName#</cfoutput></p>
<cfdump var=”#arguments.exception#” label=”OnError: exception”>
</cffunction>
i have used the onRequest method,before using my starting page of application was running properly.but not now.
and this is may on request function:
<cffunction
name=”onRequestStart”
access=”public”
returntype=”boolean”
output=”false”
hint=”I execute when a request needs to be initialized.”>
<cfargument
name=”template”
type=”string”
required=”true”
hint=”I am the template that the user requested.”/>
<cfsetting
requesttimeout=”10″
showdebugoutput=”false”/>
<cfreturn true />
</cffunction>
<cffunction
name=”onRequest”
access=”public”
returntype=”void”
output=”true”
hint=”I execute the page template.”>
<cfargument
name=”template”
type=”string”
required=”true”
hint=”I am the template that the user requested.”/>
<cfinclude template=”./index.cfm” />
<cfreturn />
</cffunction>
Sanjeet you ask how to use onerror. I pointed out in another comment in another thread that you could find several working examples showing EXACTLY how, where, and why to add error handling–specifically the onerror method of application.cfc.
Please tell us if you have read all 3 specific references I made. You should not need to ask your question of Steve if you had:
https://coldfusion.adobe.com/2016/03/new-coldfusion-training-videos-available/#comment-31549
I’m not saying this to scold but to get us all on the same page–especially since you have asked about this in two places. Let’s keep going here for now.
I will now offer more thoughts given your other comments and your original question here.
You say things don’t work.. What doesn’t work?
Is it that your index.cfm, listed in the onrequest method, does not run? And why do you have that? What if you removed it?
I realize your focus here is on error handling, and the resources I pointed to will help with that general question.
But are you currently seeing any error, on screen, in the cf application.log file?
If there’s no error in the application.log file, then it would seem you have some error handler in place, perhaps the site wide error handler. Maybe the error is being tracked somewhere in that. Again, see the resources on cf error handling that I pointed out, for more.
You must be logged in to post a comment.