try..catch vs loops

This commit is contained in:
Jindra Petřík
2021-02-07 11:10:19 +01:00
parent 7644eddfd3
commit bca83c3bb4
20 changed files with 342 additions and 109 deletions

View File

@@ -16,7 +16,7 @@
</define>
<define append="true">
<name>CONFIG::timeStamp</name>
<value>'06.02.2021'</value>
<value>'07.02.2021'</value>
</define>
<define append="true">
<name>CONFIG::air</name>

View File

@@ -16,7 +16,7 @@
</define>
<define append="true">
<name>CONFIG::timeStamp</name>
<value>'06.02.2021'</value>
<value>'07.02.2021'</value>
</define>
<define append="true">
<name>CONFIG::air</name>

View File

@@ -9,13 +9,14 @@ package
* @author JPEXS
*/
public class Main extends MovieClip
{
{
TestTryCatch;
TestTryCatchIfInTry;
TestTryCatchInIf;
TestTryCatchInWhile;
TestTryCatchInWhile2;
TestTryCatchInWhile3;
TestTryCatchInWhile4;
TestTryCatchLoop;
TestTryCatchLoopBreak;
TestTryCatchExceptionUsage

View File

@@ -12,20 +12,20 @@ package tests
{
var a:int;
a = 0;
trace("before loop");
while (a > 5)
trace("before loop"); //1-17
while (a > 5) //44-47
{
try
{
return "intry return";
return "intry return"; //20-23
}
catch(e:Error)
{
trace("in catch");
trace("in catch"); //26-43
}
a++;
a++; //26-43 cont.
}
return "OK";
return "OK";//48-50
}
}

View File

@@ -0,0 +1,37 @@
package tests
{
/**
* ...
* @author JPEXS
*/
public class TestTryCatchInWhile4
{
public function run() : void
{
var a:int;
a = 0;
while (true) {
try
{
trace("try2"); //12-21
if (a == 10){
trace("br");
break;
}
return;
}
catch(e:Error)
{
trace("in catch2");
}
trace("a=" + a);
}
trace("after"); //61-66
}
}
}

View File

@@ -13,59 +13,23 @@ package tests
{
var a:int;
a = 0;
trace("before loop");//1-15
trace("before loop");
try
{
trace("try1a");//16-22
while (a < 10){ //34-37 loop0
trace("a=" + a); //23-33
trace("in try1");
while (a < 10){
trace("a=" + a);
a++;
}
trace("try1b"); //38-44
//45-45
trace("in try2");
}
catch(e:Error)
{
trace("in catch"); //46-61
trace("in catch");
}
trace("middle");//62-68
while (a < 20) { //104-107 loop1
//69-69
try
{
trace("try2"); //70-77
return;
}
catch(e:Error)
{
trace("in catch2"); //80-103
}
trace("a=" + a); //pokračuje 80-103
}
trace("middle2"); //108-114
while (true) { //161-161 loop2
//115-115
try
{
trace("try3"); //116-122
}
catch(e:Error)
{
trace("in catch3"); //124-141
break;
}
catch(e:EOFError)
{
trace("in catch4"); //141-159
break;
}
//123-123
}
trace("exit"); //162-167
trace("after");
}

View File

@@ -0,0 +1,36 @@
package tests
{
import flash.errors.EOFError;
/**
* ...
* @author JPEXS
*/
public class TestTryCatchLoopBreak2
{
public function run() : void
{
var a:int;
a = 0;
trace("before loop");
while (a < 20) {
try
{
trace("in try");
return;
}
catch(e:Error)
{
trace("in catch");
}
trace("a=" + a);
}
trace("after");
}
}
}

View File

@@ -0,0 +1,41 @@
package tests
{
import flash.errors.EOFError;
/**
* ...
* @author JPEXS
*/
public class TestTryCatchLoopBreak3
{
public function run() : void
{
var a:int;
a = 0;
trace("before loop");
while (true) {
try
{
trace("in try");
}
catch(e:Error)
{
trace("in catch1");
break;
}
catch(e:EOFError)
{
trace("in catch2");
break;
}
}
trace("after");
}
}
}