Thursday, September 14, 2023
HomeColdFusionMistake "Kind" Isn't Constantly A String In Adobe ColdFusion

Mistake “Kind” Isn’t Constantly A String In Adobe ColdFusion

The other day, while working with Dig Deep Physical Fitness, my ColdFusion health and fitness tracker, I inadvertently took in an gotten struct as if it were an range As anticipated, ColdFusion tossed a mistake; nonetheless, my central mistake dealing with reasoning damaged since the kind home of the tossed mistake was not a string, it was an intricate Java item. I do not assume I would certainly ever before encounter this problem prior to – I have actually constantly thought that the kind, message, information, and also extendedInfo buildings were assured to be a string. I presume not.

This result is very easy to duplicate:

<< cfscript>>.

attempt {

// Produce a Purchased STRUCT.
information = [:];

// Unintentionally utilize it like a selection in CFLOOP.
cfloop( product="product", range = information) {
// ...}

} catch (any kind of mistake) {

writeDump( mistake );.



As you can see, I'm inadvertently knotting over information as if it were a range. As well as, when I attempt to do this in Adobe ColdFusion, we obtain the list below result:

ColdFusion error data structure that has a Java object as the Type property.

As you can see, the Kind home on the captured mistake is not a string however an intricate Java item. However, I have reasoning in my mistake dealing with that thinks that this worth will certainly constantly be a string; and also, that I can call string participant approaches on it. It ends up that I can not think this to be real.

ASIDE: In Lucee CFML, this does not toss a mistake since Lucee will gladly reward "range like" structs as selections

Possibly, what I require to do is a pass the mistake item via a "normalization" regular within my central mistake handling. By doing this, I can develop an item that has actually an assured framework (which assured data-types). Sort of a disappointment; however, we live and also we discover.

Wish to make use of code from this message?
Look into the certificate


Most Popular

Recent Comments