HighDots Forums  

try..finally

Javascript (German) Programmiersprache JavaScript. (de.comp.lang.javascript)


Discuss try..finally in the Javascript (German) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Chris Seidel
 
Posts: n/a

Default try..finally - 11-20-2007 , 05:12 AM






Hallo,

ich versuche gerade ein

try {
...
}
finally {
}

Wenn jedoch im try-Block ein Fehler auftritt, wird finally nicht ausgeführt.
Muss das so?
Wenn ja, kann man das try/finally irgenwie anderes erreichen?

Danke.



Reply With Quote
  #2  
Old   
Martin Honnen
 
Posts: n/a

Default Re: try..finally - 11-20-2007 , 05:32 AM






Chris Seidel wrote:

Quote:
ich versuche gerade ein

try {
..
}
finally {
}

Wenn jedoch im try-Block ein Fehler auftritt, wird finally nicht ausgeführt.
Ich habe

try {
alert(document.getElementById('notthere').innerHTM L);
}
finally {
alert('finally');
}

mit IE 6, Firefox 2 und Opera 9 getestet, Firefox und Opera führen den
finally-Zweig aus, auch wenn es kein Element mit id="notthere" gibt. IE
gibt einen Scriptfehler an und führt daher finally nicht aus.
Man kann allerdings mit IE per

try {
alert(document.getElementById('notthere').innerHTM L);
}
catch (e) {
}
finally {
alert('finally');
}

erreichen, das kein Scriptfehler angegeben wird und finally ausgeführt wird.


ECMAScript Edition 3 sagt folgendes:

The production TryStatement : try Block Finally is evaluated as follows:
1. Evaluate Block.
2. Evaluate Finally.
3. If Result(2) .type is normal, return Result(1).
4. Return Result(2).

also sollte IE/JScript einen Bug haben, finally muss ausgeführt werden.

--

Martin Honnen
http://JavaScript.FAQTs.com/


Reply With Quote
  #3  
Old   
Chris Seidel
 
Posts: n/a

Default Re: try..finally - 11-20-2007 , 08:13 AM



Martin Honnen wrote:

Quote:
also sollte IE/JScript einen Bug haben, finally muss ausgeführt
werden.
OK, danke.




Reply With Quote
  #4  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: try..finally - 11-20-2007 , 12:25 PM



Martin Honnen wrote:
Quote:
Chris Seidel wrote:
ich versuche gerade ein

try {
..
}
finally {
}

Wenn jedoch im try-Block ein Fehler auftritt, wird finally nicht ausgeführt.

[...]
ECMAScript Edition 3 sagt folgendes:

The production TryStatement : try Block Finally is evaluated as follows:
1. Evaluate Block.
2. Evaluate Finally.
3. If Result(2) .type is normal, return Result(1).
4. Return Result(2).

also sollte IE/JScript einen Bug haben, finally muss ausgeführt werden.
Was dem einen sein Bug, ist dem anderen seine standardkonforme Abweichung

Quote:
2 Conformance

[...]
A conforming implementation of ECMAScript is permitted to support program
and regular expression syntax not described in this specification.
Siehe auch http://PointedEars.de/scripts/es-matrix#try


PointedEars
--
Quote:
In [einem Popup] soll sich ein Link befinden, der im Hauptfenster
ausgeführt werden soll. Habt ihr ne Ahnung, wie man das anstellt?
Links werden niemals ausgeführt, denn es sind keine Hunde, mit denen man
Gassi geht. (Georg Maaß in dcljs <aop009$ooab4$1 (AT) ID-3551 (DOT) news.dfncis.de>)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.