• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cfscript try/catch in CF8

New Here ,
Sep 07, 2007 Sep 07, 2007

Copy link to clipboard

Copied

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.)
TOPICS
Advanced techniques

Views

676

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 07, 2007 Sep 07, 2007

Copy link to clipboard

Copied

jsmcmullen wrote:
> 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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 07, 2007 Sep 07, 2007

Copy link to clipboard

Copied

Well, that's just it. Can I trust that CF8 is handling it as local for me? Does anyone know?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 07, 2007 Sep 07, 2007

Copy link to clipboard

Copied

jsmcmullen wrote:
> 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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 07, 2007 Sep 07, 2007

Copy link to clipboard

Copied

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.)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 07, 2007 Sep 07, 2007

Copy link to clipboard

Copied

LATEST
jsmcmullen wrote:
> (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).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation