Pete Freitag Pete Freitag

Bad Error Message

Published on May 23, 2005
By Pete Freitag
coldfusion

I recently did this:

<cfoutput query="#queryName#"> ... </cfoutput>

Can you spot the error?

I think that is probably a very common mistake - here's the error message you get in ColdFusion MX 6.1:

Complex object types cannot be converted to simple values. The expression has requested a variable or an intermediate expression result as a simple value, however, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are examples of complex values. The most likely cause of the error is that you are trying to use a complex value as a simple one. For example, you might be trying to use a query variable in a CFIF tag. This was possible in ColdFusion 2.0 but creates an error in later versions. The error occurred on line 14.

I realize that this is a generic error message, but in this case - for what is probably a very common thing to do - why not something like You passed in a query object, when we expected the name of a query. You may need to remove the pound signs..



exceptions cfoutput cfml errors error message

Bad Error Message was first published on May 23, 2005.

If you like reading about exceptions, cfoutput, cfml, errors, or error message then you might also like:

FuseGuard Web App Firewall for ColdFusion

The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.

CFBreak
The weekly newsletter for the CFML Community


Comments

Or here is a crazy idea... instead of throwing an error - just work with the passed in query. ;)
by Raymond Camden on 05/23/2005 at 5:37:32 PM UTC
Yeah Ray I thought about that too, but that would create code that didn't work on previous versions of CF... not sure if that is an issue for many people?
by Pete Freitag on 05/23/2005 at 5:50:52 PM UTC
Well, the same could be said for cfdocument. It won't work in CF5 either. ;)
by Raymond Camden on 05/23/2005 at 5:52:48 PM UTC
Yes I understand that, but if your writing software that has to work on multiple versions of CF it can make it easy to introduce bugs. Again, I'm not sure if that is an issue for many people.
by Pete Freitag on 05/23/2005 at 5:59:47 PM UTC
Hi,

Iam talking with w.r.t coldfusion MX.

If ur getting an error "ByteArray Object cannot be converted to String" Follow this procedure. Here #id# is a ByteArray Object

<cfset aAbcArray = ArrayNew(1)>
<cfset aAbcArray[1] = #id#>
<cfset ArrayAppend(aAbcArray, "")>
<cfset one = aAbcArray>
<cfset one = #BinaryEncode(#id#,'Hex')#>
<cfoutput>#one<cfoutput>

Remember ByteArray Object is a complex data type and cannot be converted to simple data type. If u find this problem then use the array value directly instead of #one# value. Like this 'aAbcArray.value'

Rauf
by Rauf Khan on 05/27/2005 at 5:49:53 AM UTC
Tjarko - that is a good point, I didn't think of that...

I'm not sure why you can't get view the code in your RSS reader... I am pretty sure its all valid xml, I'll look into it.

-pete
by Pete Freitag on 06/07/2005 at 2:19:22 PM UTC
how about "cannot read your messages (bad data 1) what's with that?
by alice on 03/14/2006 at 8:39:29 AM UTC