Skip to main content
Inspiring
Mar 28, 2016 5:51 PM UTC
Question

How to find where error is occuring on a cfincluded file?

I am getting an error on index.cfm on line 424. The problem is that I include several files depending on how the page processes. Index.cfm is not 424 lines long. Is there a way to find out exactly what sub page is tripping the error? I've been over and over this but can't seem to find it.

This topic is closed to new replies. Start a new post to keep the conversation going.

6 replies

Dave Ferguson
Participating Frequently
Apr 21, 2016 3:01 PM UTC

Do you have robust exception reporting turned on?  If so you should see the stack trace and it should help point you to where the actual error is.

--Dave

Translate
Inspiring
Apr 19, 2016 8:56 AM UTC
  • Right click on the web page
  • Select 'View Page Source' from the drop down
  • view-source page opens (i.e. view-source:YourURL)
  • The line numbers are on the left of the source page
Translate
EddieLotter
Inspiring
Apr 21, 2016 2:47 PM UTC

A*** wrote:

  • Right click on the web page
  • Select 'View Page Source' from the drop down
  • view-source page opens (i.e. view-source:YourURL)
  • The line numbers are on the left of the source page

You are assuming the OP is using the same Web browser that you are. This is not necessarily the case and different browsers have different ways to view the page source. It's best to be as explicit as possible in your instructions to avoid confusion.

The line numbers you refer to are the line numbers for the rendered HTML, not the line numbers of the ColdFusion code that produced the HTML. This is not useful in this case.

Cheers

Eddie

Translate
Inspiring
Apr 21, 2016 4:18 PM UTC

You are right Eddie. The line numbers I referred to earlier are not useful in this case.

Translate
BKBK
Community Expert
Community Expert
Apr 3, 2016 12:50 PM UTC

siriiven wrote:

I am getting an error on index.cfm on line 424. The problem is that I include several files depending on how the page processes. Index.cfm is not 424 lines long. Is there a way to find out exactly what sub page is tripping the error? I've been over and over this but can't seem to find it.


Here are some easy, self-explanatory steps to follow:

index.cfm

<cftry>

...

code, code, code

...  

<cfinclude template="template1.cfm" >

...

code, code, code

...  

<cfinclude template="template2.cfm" >

...

code, code, code

...  

<cfcatch type="any" >

    <cfdump    var="#cfcatch#">

</cfcatch>

</cftry>

template1.cfm

<cftry>

...

code, code, code

...  

<cfcatch type="any" >

    <cfdump    var="#cfcatch#">

</cfcatch>

</cftry>

template2.cfm

<cftry>

...

code, code, code

...  

<cfcatch type="any" >

    <cfdump    var="#cfcatch#">

</cfcatch>

</cftry>

Three remarks:

1) the error may be in the Applicatio.cfc or Application.cfm file;

2) the try-catch is for test purposes and is not meant for production;

3) with all the cfcatch tags, this example fails the DRY rule but, hey, it is a test and a starting point.

[DRY: Don't Repeat Yourself]

Translate
Charlie Arehart
Community Expert
Community Expert
Mar 28, 2016 6:23 PM UTC

Yep, it’s a frequent challenge. There may be a solution.

First, are you saying you do or do not have an error handler in place? If you do, does a dump (of the error scope in an app or site-wide error handler, or of the catch scope in a cfcatch) show more detail, including a tagcontext that would indicate the real line in error?

Though this is the “advanced techniques” forum, some people never do learn how to use them. They’re documented in the “Developing ColdFusion Applications” (the user guide in the CF docs), or I did a 4-part series introducing them (and a later article with some updates since then). The concepts (and some challenges) have hardly changed since then. See:

http://carehart.org/articles/#2006_2

And let us know if that helps.

/charlie

Translate
/Charlie (troubleshooter, carehart. org)