I was just helping someone debug a strange ColdFusion error:
19.0 Must Be Within Range: ( 1 : 12 ). ColdFusion cannot determine the line of the template that caused this error. This is often caused by an error in the exception handling subsystem.
Because ColdFusion wasn't giving us any template or line numbers, we basically had to start commenting out code and putting it back in until we narrowed down the template and the line. And, seeing as I was not working on the project, this was particularly necessary (as I was not familiar with the code at all - just called over for the error). Finally, we narrowed it down to the ColdFusion method, MonthAsString(). This takes a month index and returns the name of the month. Therefore, running:
Launch code in new window » Download code as text file »
... gives us:
January
The values, obviously, can only be 1 - 12, as there are only 12 months in the year. As it turns out, there was some weird math algorithm that was passing a variable of the value 19 to the MonthAsString() function; hence the whole out of range error.
Good to know if I ever see this error again.
Download Code Snippet ZIP File
Comments (2) | Post Comment | Ask Ben | Permalink | Other Searches | Print Page
When I was a kid I ran across a few page insert in a day planner that had a system to calculate the day of week (Monday, Thursday, etc.) of any date between around 1500 and 2100. Years later I realized it was based on an algorithm that works for our current calendar system(Gregorian).
I suspect the 19 is a remnant of the formula. The days of week fall on a fairly predictable basis for hundreds of years based on a relatively easy formula.
http://en.wikipedia.org/wiki/Calculating_the_day_of_the_week
http://www.jimloy.com/math/day-week.htm
Posted by Ryan on Jul 31, 2007 at 12:49 AM
Cool
Posted by Nic on Aug 3, 2007 at 12:41 PM