Right. This is one of the fundamental reasons you can't use <cfscript> that much. If you wrap <Cfthrow> in another function (or use the one Raymond wrote) the error is actually throw from the throw function, not where you called the function. So the error will always show the lines of the throw function, not actually throw was called, like it should. Is there anyway to change this?
Why oh why do we have try/catch but no throw? It's like we got loops without a break command. Adam Wayne Lehman Web Systems Developer Johns Hopkins Bloomberg School of Public Health Distance Education Division -----Original Message----- From: Bryan F. Hogan [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 16, 2003 10:18 PM To: CF-Talk Subject: RE: Can I Throw within <cfscript>??? You _have_ to use cfthrow within test to throw within test. -----Original Message----- From: Andy Ousterhout [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 16, 2003 10:03 PM To: CF-Talk Subject: RE: Can I Throw within <cfscript>??? Bryan, This is not the same code. All you are doing is returning from a function call. You are NOT throwing an exception within test. Andy -----Original Message----- From: Bryan F. Hogan [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 16, 2003 9:03 PM To: CF-Talk Subject: RE: Can I Throw within <cfscript>??? Here is the answer <cftry> <!--- This line throws error ---> <cfset test1()> <cfcatch type="any"> <cfoutput>#test(message="CFCatch Exists - #IsDefined("cfcatch")#")#</cfoutput> </cfcatch> </cftry> <br> <cfscript> try { test1(); } catch(Any excpt) { writeoutput(test(message="CFCatch Exists - #IsDefined("excpt")#")); } </cfscript> <cffunction name="Test"> <cfargument name="message"> <cfset myMessage=Arguments.message> <cfreturn myMessage> </cffunction> -----Original Message----- From: Andy Ousterhout [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 16, 2003 9:34 PM To: CF-Talk Subject: RE: Can I Throw within <cfscript>??? Bryan, Here is sample code. First, observe that the two catch blocks behave differently. Second, can you replace the throw in Test with a script statement without changing the other code? <cftry> <cfset test()> <cfcatch type="any"> <cfoutput>CFCatch Exists - #IsDefined("cfcatch")#</cfoutput> </cfcatch> </cftry> <cfscript> try { test(); } catch(Any excpt) { writeoutput("<br>CFCatch Exists - #IsDefined("cfcatch")#"); } </cfscript> <cffunction name="Test"> <cfthrow message="This is a throw error"> </cffunction> Andy -----Original Message----- From: Bryan F. Hogan [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 16, 2003 8:18 PM To: CF-Talk Subject: RE: Can I Throw within <cfscript>??? Ok, I need some more information. Please post an example of your cfc and your cfml page -----Original Message----- From: Andy Ousterhout [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 16, 2003 9:00 PM To: CF-Talk Subject: RE: Can I Throw within <cfscript>??? Not what I am looking to do. I wish for the method to stop processing when I throw the exception and for control to return to the Try/Catch blocks. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. http://www.cfhosting.com