Ya I do something similar.
All my cfc's extend a basic root CFC that contains a function that
generates a common return structure which has the following elements:
- Msg, a message for the user
- isError, a flag indicating if an error occured or not.
- returnStatus, a return code (eg OK, BADQUERY, etc...)
So in your cfc you do something like:
<cfset stResult = returnStruct()>
<cftry>
<cfquery ...> ... </cfquery>
<cfcatch type="any">
<cfset stResult.isError = "true">
<cfset stResult.returnStatus = "BADQUERY">
<cfset stResult.msg = CFCATCH.Detail>
</cfcatch>
</cftry>
....
....
<cfreturn stResult>
Then in Flex on any WS or RO call if an error occured you can alert the
user and do whatever you need to do.
Mohanraj Jayaraman wrote:
>Most of my functions in the CFC return's an object
>(Struct) that has both the 'code' and 'message' apart
>from the other details you need.
>
>Here's an example
>
><cfcomponent ..
>
>
> <cffunction name="getQuery" hint=""
>returntype="struct" access="remote" >
>
> <cfargument type="struct" name="stData"
>required="yes" >
>
> <cfset var retStruct = StructNew()>
>
> <cfset retStruct['code'] = 0 >
> <cfset retStruct['message'] = "Message from Function
>getQuery: " >
>
> <cftry>
> <cfquery name="qry_getqry" datasource="#dsn#">
> your query
> </cfquery>
>
> <cfset retStruct['dpCustomQuery'] =
>queryToArray(qry_getqry) >
> <cfset retStruct['code']
> = 100 >
> <cfset retStruct['messaage']
> = 'Custom query
>data retrieved successfully' >
>
> <cfcatch type="any">
> <cfset retStruct['message'] = "Error Details :" &
>retStruct['message'] & cfcatch.Message & " " &
>cfcatch.Detail >
> </cfcatch>
> </cftry>
>
> <cfreturn retStruct >
>
> </cffunction>
>
></cfcomponent>
>
>In your Flex code , you will always get 'code' and
>'message' in your 'result' object and you can process
>your code based upon the 'code' you receive.
>
>
>Hope this helps.
>Mohanraj
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
1.2 million kids a year are victims of human trafficking. Stop slavery.
http://us.click.yahoo.com/.QUssC/izNLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~->
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/