Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7841427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:05:49+00:00 2026-06-02T16:05:49+00:00

For some reason, a piece of code that works fine on a *.cfm page,

  • 0

For some reason, a piece of code that works fine on a *.cfm page, and did work fine in a *.cfc, now is throwing an error when error is detected.

The error is:

Element SQL is undefined in CFCATCH. 

The code block where this is getting throw looks like this:

<cfcatch type="database">
    <cfset errorMessage = "
        <p>#cfcatch.message#</p>
        <p>Please send the following to a developer:</p>
        <p>#cfcatch.SQL#</p> <--- ERROR HERE
        <p>#cfcatch.queryError#</p>
        <p>#cfcatch.Where#</p>">
    some other stuff
</cfcatch>

Any thoughts?

UPDATE

Using @BenKoshy suggestion, I modified my <cfcatch> statement.

Remember K.I.S.S.? Keep It Simple Stupid

Using his method and then modifying it, I was getting more data back than I was going use, so I went with a simple version, and it works as advertised.

<cfif isDefined("cfcatch.message")>
  <cfset errorMessage = errorMessage & "<p>#cfcatch.message#</p>">
</cfif>
<cfif isDefined("cfcatch.SQL")>
    <cfset errorMessage = errorMessage & "<p>Please send the following to a developer:</p><p>#cfcatch.SQL#</p>">
</cfif>
<cfif isDefined("cfcatch.QueryError")>
    <cfset errorMessage = errorMessage & "<p>#cfcatch.queryError#</p>">
</cfif>
<cfif isDefined("cfcatch.Where")>
    <cfset errorMessage = errorMessage & "<p>#cfcatch.Where#</p>">
</cfif>

Nice and easy and it works. KISS

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:05:50+00:00Added an answer on June 2, 2026 at 4:05 pm

    Just means the error data did not contain an SQL statement. Shouldn’t assume that variable will exist for all errors:

    <cfif isDefined("cfcatch.sql")>
         <p>#cfcatch.SQL#</p>
     </cfif>
    

    Is the easy fix. Probably best to loop through the struct like this:

    <cfparam name="errorMessage" default="">
    <cfloop collection="#cfcatch#" item="this">
        <cfset errorMessage = errorMessage & "<p>#cfcatch[this]#</p>">
    </cfloop>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have piece of code that works fine on my local test server but
i have the following piece of code, that for some reason that i'm unaware
For some reason, this line of code is returning undefined for $(this).attr(href) $(a).attr(href, javascript:page('
I want to provide a piece of Javascript code that will work on any
Here I have a piece of code that should work based on what I
For some reason, a simple piece of decorator-code fails on my production machine, but
For some reason there's a variable called d that is defined immediately after I
For some reason, my spec isn't passing. It appears that @categories isn't getting to
For some reason, I am getting a weird overlapping dropdown menu glitch. It works
For some reason beyond me my html page is not finding my stylesheet. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.