Multiple throw statements and multiple catch statements : try catch « Statement « Flash / Flex / ActionScript






Multiple throw statements and multiple catch statements

 


package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){


        var sUsername:String = "";
        var erToThrow:Error;
        try {
          if(sUsername == "") {
            throw new EmptyStringException();
        
          }
          if(sUsername == undefined) {
            throw new UndefinedException();
          }
        }
        catch (erObject:EmptyStringException) {
              // Code to handle error.
        }
        catch (erObject:UndefinedException) {
          // Code to handle error.
        }
    }
  }
}

        








Related examples in the same category

1.Working with Basic try/catch Statements
2.Using return in try, after throw
3.Using return in catch
4.Catching Errors Generated by Flash
5.Catch Blocks Example