Status/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)
Created: 01/18/2013
Components: Language, Exception Handling
Versions: 10.0
Failure Type:
Found In Build/Fixed In Build: Final / 288737, 288853
Priority/Frequency: Major / Some users will encounter
Locale/System: English / Windows 7 64-bit
Vote Count: 0
Problem Description:
ColdFusion mask what exception has actually been raised under the hood, making it a guessing game how to catch said exception
Steps to Reproduce:
void function f(required numeric x){}
try {
f("not a numeric"); // a string is the wrong type passed in here, so we expect an exception
}
catch(any e){ // do a catch-all so we can check the exception type
writeOutput("Exception type from exception object: #e.type#<br />"); // this still outputs "numeric"
writeDump(e); // and let's look at the whole thing
writeOutput(e.getClass().getName()); // this tells us coldfusion.runtime.UDFMethod$InvalidArgumentTypeException
}
Actual Result:
This reports the exception as being of type "numeric", although the actual exception is of type "coldfusion.runtime.UDFMethod$InvalidArgumentTypeException". An exception of type "numeric" cannot be caught here.
Expected Result:
To be able to catch the exception type the exception is of.
The best solution here is just to blimin' tell us the correct exception in the first place, instead of reporting something different. That was just a dumb thing to do.
Any Workarounds:
Don't trust CF, but check Java.
NB: this exists in CF 9.0.1 too.
Blog article discussing how this wasted my time here:
http://adamcameroncoldfusion.blogspot.co.uk/2013/01/coldfusion-makes-hard-things-easy-easy.html#comment-771994201
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3485286
External Customer Info:
External Company:
External Customer Name: Adam Cameron.
External Customer Email:
External Test Config: My Hardware and Environment details:
Attachments:
Comments: