How does ColdFusion assign an error number/value to cfcatch.ErrNumber? I know I have to place it within a cftry/cfcatch tags. When an error is caught, I can use cfcatch.message or cfcatch.detail to see what happened but if I try to access cfcatch.ErrNumber, I get an error. How do you implement it? CFDOCS were of no use.
Not a big deal, just wondering.
<cftry>
<cfquery name='somequery' datasource='dsn'>
select foo1, foo2, foo3
from footable XXX
</cfquery>
<cfcatch type='any'>
<cfoutput>#cfcatch.message#</cfquery>
</cftry>
The snippet above would come back and say something about table not found since I added the XXX after the table name. Where would cfcatch.ErrNumber come into play here?
You aren’t seeing it because errNumber is only a valid attribute of cfcatch when the error is of type “expression”. From the docs:
So you would have to change your code to something like this: