0 Replies Latest reply on Nov 22, 2013 12:03 PM by RFarthing

    Get SQLSTATE from error routine in application.cfc?

    RFarthing

      I'm trying to use the following code in application.cfc to allow a meaningful error message for the user (dsp_error.cfm).

       

      It isn't practicle to wrap every query in in the app try/catch code; too little time or money for the project.

       

      Is there a way to get the SQLSTATE variable that appears in the debugging info the user sees without this code, the part that shows the actual SQL that is being sent to the Oracle server?

       

      The SQLSTATE usually helps me pinpoint how I failed to test/require proper values from the poor user. 

       

      Here's the code from application.cfc as I have it now:

       

      <cferror type="EXCEPTION" template="dsp_error.cfm"> 

       

      <cffunction name="onError" returnType="void" output="true">

        <cfargument name="Exception" required=true type="any"/>

        <cfargument type="String" name = "EventName" required=true/>

        <cfset admin_email="Randy.farthing@austintexas.gov; Jacque.driskell@austintexas.gov; lawrence.willis@austintexas.gov;">

        <!---  work around to prevent onError event to be fired by cflocation call --->

        <cfif isdefined("exception.rootcause")>

           <cfif StructKeyExists(arguments.exception.RootCause,"type") AND arguments.exception.RootCause.type EQ   "coldfusion.runtime.AbortException">

              <cfreturn/>

           </cfif>

        </cfif>

             

      <cfmail to="#admin_email#" from="#admin_email#" subject="#this.name# Application Error" type="text/html">

      <cfdump var="#error#" label="Error message">

      <cfdump var="#session#" label="Session scope">

      <cfdump var="#application#" label="Application scope">

      <cfdump var="#request#" label="Request scope">

      <cfdump var="#form#" label="Form scope">

      <cfdump var="#url#" label="URL scope">

      <cfdump var="#cookie#" label="Cookie scope">

       

      <p><b>Error on page:</b>  #error.template#</p>

      <p><b>Error Date/Time:</b> #error.datetime#</p>

      <p><b>Error Type:</b>#error.type#</p>

      <p><strong>User's Browswer:</strong> #error.Browser#</p>

      <p><strong>URL Parameters:</strong> #error.QueryString#</p>

      <p><strong>Previous Page:</strong> #error.HTTPReferer#</p>

       

      <p>#error.diagnostics#</p>

       

      <cfdump var="#error#" label="Errors">

      <cfdump var="#URL#" label="URL">

      <cfdump var="#Form#" label="Form"> 

      </cfmail>

      </cffunction>

       

      Thanks in advance.