House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

cfcatch type="" problem

  << Previous Post |  RSS |  Tree View |  Sort Oldest First |  Subscribe to this Group Next >> 

cfcatch type="" problem

Thanks James! Adrian Lynch 11/21/2008 07:27 AM
You could examine cfcatch.message to see if it matches the type of James Holmes 11/21/2008 06:54 AM
I'm caching some objects in an admin object and I serve these cached object Adrian Lynch 11/21/2008 06:03 AM

11/21/2008 07:27 AM
Author: Adrian Lynch Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:58155#315760 Thanks James! I've changed the try/catch to: <cftry>   <cfset VARIABLES.services[ARGUMENTS.service] = CreateObject("component", "cfc.#ARGUMENTS.service#Service").init()>   <cfcatch type="any">     <cfif CFCATCH.Message EQ "Could not find the ColdFusion Component or Interface cfc.#ARGUMENTS.service#Service.">       <cfthrow type="" message="No such service: #ARGUMENTS.service#<br />#GetCurrentTemplatePath()#">     <cfelse>       <cfrethrow>     </cfif>   </cfcatch> </cftry> This now throws my own exception when the service doesn't exist and let's others through. Ta. Adrian Building a database of ColdFusion errors at http://cferror.org/ You could examine cfcatch.message to see if it matches the type of exception you want. If so, handle it, if not, use cfrethrow. However, since your error handling is essentially just throwing your own description of the same error, can you just allow the original error to be thrown? mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ > I'm caching some objects in an admin object and I serve these cached object ----- Excess quoted text cut - see Original Post for more ----- CreateObject("component", > "cfc.#ARGUMENTS.service#Service").init()> >                <cfcatch type="any"> >                        <cfthrow type="" message="No such service: #ARGUMENTS.service#<br ----- Excess quoted text cut - see Original Post for more -----
11/21/2008 06:54 AM
Author: James Holmes Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:58155#315759 You could examine cfcatch.message to see if it matches the type of exception you want. If so, handle it, if not, use cfrethrow. However, since your error handling is essentially just throwing your own description of the same error, can you just allow the original error to be thrown? mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ ----- Excess quoted text cut - see Original Post for more -----
11/21/2008 06:03 AM
Author: Adrian Lynch Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:58155#315758 I'm caching some objects in an admin object and I serve these cached object up in a method, admin.getService("myService"). Some simplifed code: <cfif NOT StructKeyExists(VARIABLES.services, ARGUMENTS.service) OR ARGUMENTS.refresh>   <cftry>     <cfset VARIABLES.services[ARGUMENTS.service] = CreateObject("component", "cfc.#ARGUMENTS.service#Service").init()>     <cfcatch type="any">       <cfthrow type="" message="No such service: #ARGUMENTS.service#<br />#GetCurrentTemplatePath()#">     </cfcatch>   </cftry> </cfif> The try/catch is there to trap calls to service CFCs that don't exist. admin.getService("notAService") will throw an exception: No such service: notAService C:\path\to\template.cfc The trouble with the try catch is that it also traps errors in the service object. I've tried changing the type of the catch so I only catch the non-existent CFC exceptions but none seem to work. Any suggestions? Thanks. Adrian Lynch http://www.halestorm.co.uk/ http://www.adrianlynch.co.uk/
<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 24, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference