views:

59

answers:

2

So I have this error on a feed that magically stopped working for no reason.

The error i get is "The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.

Null Pointers are another name for undefined values. "

OK, i look up Null pointers and Ben Nadel (god bless him) has a blog post on date variables not actually being dates.

So i test for the dates not being dates. Result is True. My date variables ARE dates. Good.

Any suggestions on how to debug further?? I have output the variables i'm inserting and all looks good and matches up. The feed is processing about 55 records which won't make a difference. I have also tried other feed files to see if it was rogue data causing the issue but that didn't work either.

Cheers,

Leigh

A: 

You should make sure all your variables are fine, not only dates.

Simplest way is to wrap the accessed variable into the isDefined("varname") check.

Other solution would be to wrap each iteration code into the try/catch and log the details, including context and line. For example, something very detailed:

<cflog type="error" file="blahblah" text="#cfcatch.message# [#cfcatch.detail#], error of type #cfcatch.type# in #cfcatch.TagContext[1].template# at line #cfcatch.TagContext[1].line#:#cfcatch.TagContext[1].column#. Code context: #cfcatch.TagContext[1].codePrintPlain#" />

Note: line value may be inaccurate in Adobe ColdFusion, though Railo is much better with this.

Sergii
Thanks Sergii, i'll give it a go.
Feris
The line value in Adobe ColdFusion is always exactly right. The only thing to note with things like CFQuery blocks is that the error will show as being the last line of the cfquery tag.
Stephen Moretti
I think the comment about line numbers simply meant that the main number does not _necessarily_ point to the exact line of code you need to fix. It usually does, but sometimes you need to look a little deeper.
Leigh
+1  A: 

I agree with wrapping your output code in a cftry/cfcatch, but something that might be more useful is to use cfdump to get the full cfcatch error and also the element in your feed that is throwing an error.

There are a couple of little used attributes on the cfdump tag that are pretty useful. format and output. format will allow you to specify the output type of text or html. Output allows you to write the contents of the cfdump to a file.

<cfdump var="#cfcatch#" format="html" output="somepath\FeedCFCatch.html">
<cfdump var="#theFeedElement#" format="html" output="somepath\BrokenFeedElements.html">

Being able to see the actual "broken" element should make it obvious exactly what the problem is. Chances are its an attribute that isn't being passed through in the specific feed element.

Stephen Moretti