Skip to main content
Inspiring
November 29, 2010
Answered

Bringing "Variables Scope" in to onError(). Is it Possible?

  • November 29, 2010
  • 2 replies
  • 738 views

I’m trying to access the Variables scope ( <cfdump var=”#variables#”> ) inside the OnError() in Application.cfc for debugging and logging reasons. Something like this :

<cffunction name="onError" returnType="void" output="true">
  <cfargument name="exception" required="true">
  <cfdump var=”#variables#”>
</cffunction>

With good old Application.cfm and <cferror> I was able to access Variable Scope, just like URL or Session Scope. But OnError() been a function, it seems don’t have access to Variables Scope. Is there any possibility of
bringing Variables Scope in to OnError(), when it triggered? Or is that entirely not possible?

Thanks you in advance for your brain power!
- Sam

This topic has been closed for replies.
Correct answer Adam Cameron.

Well it's a bit of an architectural change, but if you run your app through an onRequest() event handler, using , then the whole request runs in the memory scope of Application.cfc, so all your request's variables-scoped stuff will be in the same variables scope as exposed to onError().

--

Adam

2 replies

Adam Cameron.Correct answer
Inspiring
November 30, 2010

Well it's a bit of an architectural change, but if you run your app through an onRequest() event handler, using , then the whole request runs in the memory scope of Application.cfc, so all your request's variables-scoped stuff will be in the same variables scope as exposed to onError().

--

Adam

Owainnorth
Inspiring
November 30, 2010

Have you tried using the onError method to simply use a cfinclude on an error handling .cfm page? That page *should* then have access to your variables scope as the page itself will be within the same scope.

I could, however, be awfully wrong.

SamanAuthor
Inspiring
November 30, 2010

Your suggestion brought me a new train of thought that confirmed by Adam (he always does!). I’m back on track!

Thank you very much guys!