Title:
Bug 83525:(Watson Migration Closure)I’m using CF as a backend to a Flex application
| View in TrackerStatus/Resolution/Reason: Closed/Won't Fix/LowImpact
Reporter/Name(from Bugbase): Devin Holloway / Devin Holloway (Devin Holloway)
Created: 07/09/2010
Components: Language, Exception Handling
Versions: 9.0.1
Failure Type: Unspecified
Found In Build/Fixed In Build: RC Refresh /
Priority/Frequency: Normal / Unknown
Locale/System: English / Platforms All
Vote Count: 2
Problem:
I’m using CF as a backend to a Flex application. Originally, when Flex was requesting data from CF, I could throw an exception if certain conditions weren’t met and handle that exception in the Flex’s RemoteObject fault handler. For example:<cffunction name="getUser" returntype="User"> ... <cfif not isDefined("local.user")> <cfthrow message="User not found" ...> </cfif> <cfreturn local.user></cffunction>When that exception makes its way back to the Flex fault handler, I could look at the details of the fault event and decide what to do.I then decided to filter all remoting calls through the onCFCRequest() and have found that I cannot get the original exception sent back to Flex. No matter what I try, Flex always recieves the exact same fault event with a message of:"faultCode:Server.Processing faultString:’Unable to invoke CFC - Event handler exception.’ faultDetail:’An exception occurred while invoking an event handler method from Application.cfc. The method name is: OnCfcRequest.’"Which means it never gets the specific exception I threw and therefore I can’t make a decision on what to do based on the exception.I’ve tried to simply rethrow the original exception...<cffunction name="onCFCRequest"> ... <cftry> <cfinvoke component="#arguments.cfcname#" ... returnVariable="local.result"> <cfcatch> <cfrethrow> </cfcatch> </cftry> <cfreturn local.result></cffunction>I’ve even tried manually throwing the same exception: <cftry> <cfinvoke component="#arguments.cfcname#" ... returnVariable="local.result"> <cfcatch> <cfthrow message="User does not exist" ...> </cfcatch> </cftry>But again, Flex always receives that builtin exception type rather than my custom exception. Is this a bug? Or do just not know how to get this working with onCFCRequest?
Method:
Thanks for bringing it up. We did some investigation at our end and the behavior is exactly as you say. However it seems that it is not an onCFCRequest issue but a general issue with serializing throwable CF objects.When any request is thrown from event handler functions like onrequest() et al, we wrap it with Event handler exception. So if you check its cause using getCause() it will show the actual error. But this information is not getting serialized into the flex object being created and hence you are not getting your expected exception.As for a work around, this can be achieved by returning the exception message instead of a throw. May be wrap your code with try/catch and update your return variable with error messagePlease log a bug for properly serializing throwables.
Result:
"faultCode:Server.Processing faultString:’Unable to invoke CFC - Event handler exception.’ faultDetail:’An exception occurred while invoking an event handler method from Application.cfc. The method name is: OnCfcRequest.’"
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3041754
External Customer Info:
External Company:
External Customer Name: Devin Holloway
External Customer Email: 5E060FD6422E831A992015D5
External Test Config: 07/09/2010
Attachments:
Comments: