Flash / Flex / ActionScript/Statement/throw
Rethrowing Exceptions
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
try
{
try
{
throw new Error();
} catch (error:Error) {
trace("inner handler");
throw error;
}
} catch (error:Error) {
trace("outer handler");
}
}
}
}
throw Error in a function
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var sUsername:String = tUsername.text;
try {
checkUsername(sUsername);
}
catch (erObject:Error) {
trace("An error was thrown.");
}
}
function checkUsername(sUsernameParam:String) {
if(sUsernameParam == "") {
throw new Error();
}
}
}
}