ColdFusion Muse

Tip on Showing Errors in Your CFC

Mark Kruger December 20, 2005 9:46 AM Coldfusion Tips and Techniques Comments (9)

When you are debugging a CFC and you throw an error, you sometimes get a dreaded "page cannot be displayed" message. The reason this pops up is that the "output" attribute of the component is set to "no". If you set the output to "yes" you will see the full error messages.

<cfcomponent output="yes" ....>
...
</cfcomponent>
Remember, there are usually good reasons to set it to "no". When you have finished debugging it probably should be set to "no" - unless you are using CFC's to display or send data back to the user. That's not the way I like to do it. Pages or custom tags are fine for display, CFCs are for data and logic - at least that's my take.

  • Share:

9 Comments


Leave this field empty

Write a comment

If you subscribe, any new posts to this thread will be sent to your email address.

  • Doug Hughes's Gravatar
    Posted By
    Doug Hughes | 12/20/05 8:55 AM
    Actually, if you're getting this message in IE it's because IE is configured to show friendly error messages and not the actuall error. CF sends an error 500 header when errors occur. I think that by outputing data with the output="yes" setting that you're actually just tricking IE into displaying the error.

    That said, have you tried this? Click Tools > Internet Options > Advanced. From here find the Show friendly HTTP error messages and uncheck it.

    That'll cause the CF error to always be displayed.
  • mkruger's Gravatar
    Posted By
    mkruger | 12/20/05 9:11 AM
    Doug - you are probably right. I'll check it out later. Either way though - setting the output to "yes" allows you to see the error message correctly.
  • dan's Gravatar
    Posted By
    dan | 12/20/05 10:17 AM
    I agree with the fact that CFCs are for data and logic, 99% of the time. There was a good article in CFDJ about using CFCs as layout managers and I think it has some strong advantages.If you have not got a chance to read it check it out. Overall though I agree with you!
  • mkruger's Gravatar
    Posted By
    mkruger | 12/20/05 10:26 AM
    Dan - thanks for the tip on the article. I'll look for it.
  • Julie Lorraine Jackson's Gravatar
    Posted By
    Julie Lorraine Jackson | 1/19/06 11:09 AM
    I SAID WHY WHY WHY ERROR E MAIL I TRY REACH MY FRIEND TOO FROM JULIE LORAINE JACKSON
  • Julie Lorraine Jackson's Gravatar
    Posted By
    Julie Lorraine Jackson | 1/19/06 11:19 AM
    i TRY E MAIL TO JASON RITTER AS ERROR I DON'T UNDERSTAND THIS COMPUTER FROM JULIE LORRAINE JACKSON
  • julie lorraine jackson's Gravatar
    Posted By
    julie lorraine jackson | 2/1/06 9:56 AM
    weird sometimes computer anyway Stu can bring to man to his computer fixing soon FRom Julie Lorraine Jackson
  • julie lorraine jackson's Gravatar
    Posted By
    julie lorraine jackson | 2/2/06 3:49 PM
    weird sometimes computer anyway Stu can bring to man to his computer fixing soon FRom Julie Lorraine Jackson
  • mkruger's Gravatar
    Posted By
    mkruger | 2/2/06 4:02 PM
    You know - I have no idea what this thread is about... Julie's email?