Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / September 2007



Tip: Looking for answers? Try searching our database.

cfscript try/catch in CF8

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jsmcmullen - 07 Sep 2007 16:10 GMT
I am having an issue in CF8 that I did not see in earlier versions. Consider
this code inside a function in a CFC:

<cfscript>
    var err1 =  0;
    try {
        some code here;
    } catch (Any err1) {
        some code here;
    }
</cfscript>

In CF8, I am getting the error "Cannot declare local variable err1 twice" when
I try to instantiate the CFC. Of course, I get no error if I get rid of the var
err1 = 0 line, but is this thread-safe? (Changing the variable declaration to
"var err1 = structtNew() doesn't work either.)
GArlington - 07 Sep 2007 16:54 GMT
> I am having an issue in CF8 that I did not see in earlier versions. Consider
> this code inside a function in a CFC:
[quoted text clipped - 12 lines]
> err1 = 0 line, but is this thread-safe? (Changing the variable declaration to
> "var err1 = structtNew() doesn't work either.)

It behaves the same way in CF7.
Error var is by default local (it is created only if error occurs ->
no need to define as local.
PaulH **AdobeCommunityExpert** - 07 Sep 2007 17:17 GMT
>  In CF8, I am getting the error "Cannot declare local variable err1 twice" when

if you believe the error message cf8's handling the err1 var as local for you.
jsmcmullen - 07 Sep 2007 18:37 GMT
Well, that's just it. Can I trust that CF8 is handling it as local for me? Does anyone know?
PaulH **AdobeCommunityExpert** - 07 Sep 2007 18:48 GMT
> Well, that's just it. Can I trust that CF8 is handling it as local for me? Does anyone know?

cf's telling you that it is. i was being facetious about trusting the error message.
jsmcmullen - 07 Sep 2007 19:05 GMT
Okay, that's cool. Thanks.

(I never understood why you have to pass in an error variable there anyway.
You don't have to in the cfcatch tag -- only in the cfscript -- and it isn't a
variable that you actually populate beforehand.)
PaulH **AdobeCommunityExpert** - 08 Sep 2007 03:17 GMT
>  (I never understood why you have to pass in an error variable there anyway.
> You don't have to in the cfcatch tag -- only in the cfscript -- and it isn't a
> variable that you actually populate beforehand.)

i imagine for you to control & it's not like cfcatch where the var is already
reserved (cfcatch struct).
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.