[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Nested try catch

Andrew Poulos

7/21/2014 12:24:00 AM

If I have this

try {
// blah
} catch(e) {
try {
// blah 2
} catch(e) {}
}

jslint.com says "'e' is already defined" - fair enough. But if I change
it to

try {
// blah
} catch(e) {
try {
// blah 2
} catch(e2) {}
}

jslint.com says "Expected 'ignore' and instead saw 'e2'".

Is 'ignore' just a variable name that jslint.com prefers?

Andrew Poulos
4 Answers

Thomas 'PointedEars' Lahn

7/21/2014 1:58:00 AM

0

Andrew Poulos wrote:

> If I have this
>
> try {
> // blah
> } catch(e) {
> try {
> // blah 2
> } catch(e) {}
> }
>
> jslint.com says "'e' is already defined" - fair enough. But if I change
> it to
>
> try {
> // blah
> } catch(e) {
> try {
> // blah 2
> } catch(e2) {}
> }
>
> jslint.com says "Expected 'ignore' and instead saw 'e2'".
>
> Is 'ignore' just a variable name that jslint.com prefers?

Given that jslint.com reports identifiers that are clearly block-scoped per
Specification as global variables, I would not put too much weight on what
jslint.com has to say.

This is just one of jslint.comâ??s many idiosyncrasies imposing Douglas
Crockfordâ??s defective perception of ECMAScript and its implementations on
developers: If the â??catchâ? block is empty (not considering comments), he/it
expects the identifier for the exception value to be â??ignoreâ?, and anything
else is considered an error; otherwise the identifier â??ignoreâ? is considered
an error.

ISTM that jslint.com checks grow more rediculous by the year. Perhaps
Douglas Crockford cares to explain what is so bad about block code indented
with two spaces instead of four? I would not mind making additional checks
optional, but to make them the default is highly presumptuous of him.

My advice: Just ignore the new Crockford, his books, and jslint.com.

--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Joao Rodrigues

7/21/2014 3:19:00 AM

0

On 07/20/2014 09:23 PM, Andrew Poulos wrote:
> If I have this
>
> try {
> // blah
> } catch(e) {
> try {
> // blah 2
> } catch(e) {}
> }
>
> jslint.com says "'e' is already defined" - fair enough.

Maybe this is due to an old problem with the try...catch block in IE 8
and earlier.


> But if I change
> it to
>
> try {
> // blah
> } catch(e) {
> try {
> // blah 2
> } catch(e2) {}
> }
>
> jslint.com says "Expected 'ignore' and instead saw 'e2'".
>
> Is 'ignore' just a variable name that jslint.com prefers?

Yes, "ignore" is meant to be used as one of the "Crockfordian"
assumptions. See the 'ignore' check in the jslint code:
<https://github.com/douglascrockford/JSLint/blob/master/jsl...

<http://stackoverflow.com/questions/16613790/jslint-error-expected-ignore-and-instead-...

--
Joao Rodrigues

Hans-Georg Michna

7/21/2014 6:38:00 AM

0

On Mon, 21 Jul 2014 10:23:40 +1000, Andrew Poulos wrote:

>try {
> // blah
>} catch(e) {
> try {
> // blah 2
> } catch(e2) {}
>}
>
>jslint.com says "Expected 'ignore' and instead saw 'e2'".
>
>Is 'ignore' just a variable name that jslint.com prefers?

Yes. My thought on this is that it is not a bad idea to call the
ignored exception 'ignore'. I do that in my programming as well,
have done it already before learning that jslint likes it too.

But it is only a recommendation. You don't have to follow it.

Hans-Georg

Michael Haufe (\"TNO\")

7/21/2014 12:09:00 PM

0

On Sunday, July 20, 2014 7:23:40 PM UTC-5, Andrew Poulos wrote:
> If I have this
>
> try {
> // blah
> } catch(e) {
> try {
> // blah 2
> } catch(e) {}
> }
>
> jslint.com says "'e' is already defined" - fair enough. But if I change
> it to
>
> try {
> // blah
> } catch(e) {
> try {
> // blah 2
> } catch(e2) {}
> }
>
> jslint.com says "Expected 'ignore' and instead saw 'e2'".

> Is 'ignore' just a variable name that jslint.com prefers?

use jshint.com instead